How does bundler work (in general)?

2020-08-09 10:12发布

问题:

I'm pretty new to Ruby/Rails but I was taking a look at bundler and was wondering how it works exactly. Do you install a full set of gems like normal gem install XYZand then use the Gemfile to pull a certain subset of those gems for use with a specific application? Or do you not install gems normally anymore and just include them in the Gemfile and then do a bundle install to include them all in a bundle that is then used with your application?

Thank you so much for taking the time to answer this, I'm just a little confused on what bundler's functionality is exactly.

-- MAP

回答1:

Think of bundler as a package management tool.

From bundle help command:

bundle install # Install the current environment to the system

bundle package # Locks and then caches all of the gems into vendor/cache

So bundle install command will install all gems to the system that are listed in Gemfile as well as their dependencies. If the gem was not previously installed it will grab it from the gemcutter repo. bundle package will cache the .gem files into your apps vendor/cache directory.

No need to run gem install first.



回答2:

These two links explain everything about bundler.

  • How does bundler bundle

  • How does bundle require gems