Where Does Bundler Store Gems

Where does bundler store gems?

It depends. In the usual development setup they are installed where they would be when you install a gem "normally" (by running gem install foo) and bundler won't reinstall gems that are already there. This location depends on how rubygems itself is configured.

If you run bundle install with the --deployment option then the gems will be installed in a location unique to your app (you can pass this as a separate option but it defaults to vendor/bundle)

You can also run bundle package to store all the .gem files your app uses in vendor/cache. Running bundle install will prefer gems in vendor/cache to gems in other locations.

Why Bundle Install is installing gems in vendor/bundle?

  1. Use bundle env to view paths and bundle configuration

  2. After this set bundle path to ~/.rvm/gems/ruby-2.0.0-p247 like this:

    bundle install --path ~/.rvm/gems/ruby-2.0.0-p247

    which is global and also you can use your own custom path.

  3. Post this bundle install will never need path again and will always install all of your gems in that directory(~/.rvm/gems/ruby-2.0.0-p247 in my case) for that app not in app_folder/vendor/bundle

Bundler: install local gem with system gems

No, Bundler treats path gems differently and does not install them to your GEM_PATH. This is so that you don't need to reinstall as you make changes.

It is not normal or necessary for a gem to point to itself or its runtime dependencies in its Gemfile. You might want to add gemspec to do this automatically. See http://bundler.io/v1.3/rubygems.html

How to find where gem files are installed

Use gem environment to find out about your gem environment:

RubyGems Environment:
- RUBYGEMS VERSION: 2.1.5
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-darwin12.4.0]
- INSTALLATION DIRECTORY: /Users/ttm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0
- RUBY EXECUTABLE: /Users/ttm/.rbenv/versions/2.0.0-p247/bin/ruby
- EXECUTABLE DIRECTORY: /Users/ttm/.rbenv/versions/2.0.0-p247/bin
- SPEC CACHE DIRECTORY: /Users/ttm/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/ttm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0
- /Users/ttm/.gem/ruby/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/ttm/.rbenv/versions/2.0.0-p247/bin
- /Users/ttm/.rbenv/libexec
- /Users/ttm/.rbenv/plugins/ruby-build/bin
- /Users/ttm/perl5/perlbrew/bin
- /Users/ttm/perl5/perlbrew/perls/perl-5.18.1/bin
- /Users/ttm/.pyenv/shims
- /Users/ttm/.pyenv/bin
- /Users/ttm/.rbenv/shims
- /Users/ttm/.rbenv/bin
- /Users/ttm/bin
- /usr/local/mysql-5.6.12-osx10.7-x86_64/bin
- /Users/ttm/libsmi/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/bin

Notice the two sections for:

  • INSTALLATION DIRECTORY
  • GEM PATHS

Bundler installing gem that's already installed

Try running bundle env to verify that the install location is what you expect.

If not, check whether there is a .bundle/config or ~/.bundle/config file overriding the install path. The output of bundle env will tell you what configuration it is using and how it was determined (i.e., which file it was in or whether it was picked up from an environment variable).



Related Topics



Leave a reply



Submit