简体   繁体   中英

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.

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).

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM