Difference between bundle and gem install?

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.


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.