Spencer Cooley
Spencer Cooley

Reputation: 8851

I don't completely understand the gemfile in a rails application

What is the difference between installing a gem from the command line

sudo gem install gem-name

and writing your gem into the Gemfile and running bundle install?

I think the problem is that I don't understand the exact purpose of the Gemfile. So far it seems like it is a place to list all of the gems that your app is dependent on.

Upvotes: 5

Views: 1201

Answers (3)

Joris Ooms
Joris Ooms

Reputation: 12038

I always thought you write all gems that your app is dependent on in it, and then if you want to port your application somewhere else, you can run the bundle install and it'll grab the gems you need for you so you don't manually have to do it.

This might clear things up, I quote:

'It holds information about all the project dependencies so that you don't need to struggle to figure out what gems you need to install.'

http://blog.despo.me/42762318

Upvotes: 1

Chris Cherry
Chris Cherry

Reputation: 28554

The best source of the whats and whys about Bundler, is probably this page:

http://gembundler.com/rationale.html

That page has great examples and explanation about why Bundler is useful and in some cases, necessary.

Upvotes: 2

Mike Lewis
Mike Lewis

Reputation: 64137

Installing a gem via:

sudo gem install gem-name

is going to install that gem system wide.

Whereas installing them via the Gemfile is specific for your rails app(to keep track of dependencies, version, app portability etc).

Upvotes: 3

Related Questions