Difference between bundle and gem install?
I am pretty sure this is a very basic question but as a RoR newbie I'd like to understand why sometimes I use bundle install (which from my undertanding install all Gems and their dependecies from Gemfile) and gem install [gemname]?
What are the fundamental differences between both and when would I favour gem install inst开发者_开发知识库ead of bundle install?
Thanks! Rog
I'd say: by default on your local machine, no particular difference but...
The purpose of bundle install
is to setup everything for the application containing the Gemfile
. You can even pass arguments to make needed gems installed in whatever folder you want.
This way in production, you have clearly separated apps with their own gems.
On the other side, gem install gmaps4rails
(easy advertisement) gets the gem installed for your whole environment.
I used to think there's no difference between adding a gem to the gemfile and then running 'bundle install' or doing 'gem install x'. I thought it's similar to doing 'yarn add package' vs. adding the package to package.json and then running 'yarn'.
However, while trying to set up the chamber gem for rails, I noticed how only after running 'gem install chamber' I was able to use the chamber command 'chamber init'. Before, when I had only added it to the gemfile and hit bundle install, running 'chamber init' would get me a 'unknown command chamber' error in my terminal.
Interesting..
Almost seems like running 'gem install' adds it to the global available gems (and hence terminal can run the package's commands), whereas adding it to the gemfile and running bundle install only adds it to the application. Similar to npm install --global.
精彩评论