3

New machine. New rbenv install. New rbenv-gemset install. New ruby-2.0.0 install. New rails 4.0.0 app.

When I

$ bundle install

from the rails app directory, I get

Your bundle is complete!
It was installed into ./vendor/bundle

But, if I then

$ gem list

none of the gems that were supposedly installed show up.

I have run

$ rbenv rehash

Why could this be?

Additional info:

$ which bundle
/usr/local/var/rbenv/shims/bundle
$ rbenv which bundle
/usr/local/var/rbenv/versions/2.0.0-p247/bin/bundle
$ rbenv which ruby
/usr/local/var/rbenv/versions/2.0.0-p247/bin/ruby
$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
$ rbenv gemset active
blog
$ which rails
/usr/local/var/rbenv/shims/rails
dpdawson
  • 488
  • 4
  • 9
  • 2
    `gem list` does not show bundled gems that are installed in vendor. Try `bundle list` instead. `gem` != `bundle`. – Casper Jul 06 '13 at 11:21

1 Answers1

4

Your default in this app is to install to vendor/bundle. You can tell this by It was installed into ./vendor/bundle text which appears after gems installation.

Bundler documentation specifies that you have to pass --system to install in system location:

--system: Install to the system location ($BUNDLE_PATH or $GEM_HOME) even
          if the bundle was previously installed somewhere else for this
          application

EDIT: More explanation is that your ruby knows only about gems installed with --system option when not using bundle exec. You can see your gems from vendor/bundle or whatever path you've chosen by running bundle exec gem list or (as Casper noticed) bundle list. Now it is your choice whether you want your gems in system location or in application directory.

Lucas
  • 2,587
  • 1
  • 18
  • 17
  • Thanks. OK, so, assuming I want my gems in the application directory, how do I wire that up with the application's rbenv gemset? – dpdawson Jul 06 '13 at 11:42
  • If you have your gems only in scope of one application, why do you need gemset at all? I guess you can't use both gemset and `--path` option. Try `bundle --system` and then your gems should be in gemset. – Lucas Jul 06 '13 at 12:54
  • `bundle list` lists all the gems installed for e.g. for capistrano deployed app. By default for capistrano deployed apps the gems gets installed under folder `//shared/bundle/ruby`. Running `gem list` from `/current` folder like `/current$ gem list` just lists the globally installed gems. To view the list of gems installed for the application we should run `/current$ bundle list`. – Jignesh Gohel Aug 08 '16 at 21:29