0

Related to this but not the same.

I am new to Rails and even with Ruby usually I only do console utilities to do a very particular things that I need to do.

I would like to learn more about Rails and try out some open source Rails applications. For discussion sake, let's say I would like to setup Storytime CMS.

In the installation guide, it says I need to add gem storytime to my Gemfile. While I know how to do this and I know this is the equivalent (sort of) to gem install storytime, what I don't understand is: What is the different between

  1. gem install storytime
  2. Clone the git repository and run bundle install

And further to that, in my current machine, after cloning git repository, running bundle install (yes I have bundler gem installed) gave me an error. While gem install storytime went successfully.

Also, the guide says "Add Storytime to your Gemfile". If I started from scratch, I don't have Gemfile yet. Is that when I need to do bundle init first?

I know this is quite newbie question but I have searched about this and can't get any clear info. Thanks a lot.

Pelangi
  • 401
  • 1
  • 4
  • 6
  • yeah you can do bundle init first or just create a `Gemfile` manually and make sure the first line is `source "http://rubygems.org"` – max pleaner Sep 07 '17 at 03:56
  • So in what situation I would want to clone git repo and run `bundle install`? – Pelangi Sep 07 '17 at 06:15
  • not everyone gets around to packaging their code as a gem, so sometimes you have to. Other times it can be useful to clone the source to make some slight changes, e.g. a fork. – max pleaner Sep 07 '17 at 06:31

1 Answers1

0

Gems are rubys packaging mechanism. It is a way to distribute packaged ruby code through a centralized service (rubygems.org). Developers can build gems and upload them to rubygems.org so other developers have easy access to the "gemified" source code.

Note: "Centralized" is a simplification: you can setup your own gem-server and use this one instead. This is useful for private gems.

When you do a git clone then you download the source code from a Git repository (usually github.com, but can be something different).

You can also have bundler fetch Gems from a git repository. This is convenient, when you need a specific version of the gem that has not been released yet. I.e. the fix for a bug has been commited to the repository but no new version has been released.

So in short, I'd put it like: Git: where developers work on the code, enhance it Gem: packaged, snapshot of code

Pascal
  • 8,464
  • 1
  • 20
  • 31