Difference between bundle show gemname and gem list gemname
The confusion comes from the issue bundler is solving.
When you install Gems into your system-wide gem repository you end up with multiple versions of the gem once you have a couple of apps.
So for example you could end up with 3 Rails versions: 3.2.8, 3.2.6 and 3.1.0
If you do a require rails
rubygems could use any of these versions and you'll end up with confusion if your App that was initially built against 3.1.0 isn't compatible with some change s in 3.2.8.
What bundler does is install exactly the gems that are specified in the Gemfile.lock and locks those down for the use of that app. Bundler therefore modifies the load-paths for rubygems so only the Gems in the Gemfile.lock are really available to the app.
Therefore bundle install
is not installing gems into the system-wide gem directory but rather installs to a different path for each project. That's why you see the gem in a bundler directory and not system wide.
If you install rack-cache
through gem install
you'll also see it in gem list
.
In RVM, gem list command does not show installed gems
bundle install
will install the gems to the vendor/cache
directory within a rails app, which does not install them in the gems directory. To list the gems installed by bundler, use bundle list
bundle package with rvm
As per my comment. You didn't run package after adding devise to your gem file which is why it isn't in vendor/cache. Bundle install still needs to install the gems on your system.
From bundler website
The package command will copy the .gem files for your gems in the bundle into ./vendor/cache. Afterward, when you run bundle install,
Bundler will use the gems in the cache in preference to the ones on rubygems.org.Additionally, if you then check that directory into your source
control repository, others who check out your source will be able to
install the bundle without having to download any additional gems.
The rvm gemset and bundler solve some of the same problems with which set of gems/versions are to be used / activated. With bundler now you don't need to use rvm gemsets , the gemfile handles it. But this wasn't always the case.
Why does RVM gem list shows gems I did not install?
most likely this happens because the global gemset contains all
the gems, try:
rvm 1.9.2@global gem list
you can compare this with gem list to see only your gems:
rvm use 1.9.2
diff --normal <(gem list) <( rvm 1.9.2@global gem list ) | sed '/^[^<]/ d ; s/^< //'
or using only GEM_HOME
as GEM_PATH
:
GEM_PATH=$GEM_HOME gem list
Gem list doesn't show bundler after Successfully installed bundler
The PATH
of the root user is likely not the same as the PATH
of your current user. Therefore the gem
command that root loads will not be the same as the gem
command you load as a normal user. This makes sudo gem install
save the gems into a different location (the location of the Ruby installation found in the PATH
of the root user).
To fix this issue, the most straightforward solution is to force root to use the same gem command by giving it the full path:
sudo `which gem` install ...
Note the use of backticks. Using backticks this way, the command will essentially expand to something like:
sudo /some/path/to/the/user/ruby/installation/bin/gem install ...
To figure out if the gem
command of root is different from your default gem
command, you can do this:
# As normal user check output of this command
which gem
# ..and compare it to the output of this command
sudo which gem
RVM project specific gems
In your .rvmrc
write following code:
rvm use <ruby_version>@<project_name> --create
In my case ruby_version
is ruby-1.9.3-p194
Once you navigate to your project path, run bundle install
to install all the gems specific to your project.
Gems not in Local Gems after bundle install
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.
Related Topics
Cucumber: Automatic Step File Creation
Intelligently Generating Combinations of Combinations
Rails: Allowing a Partial to Only Be Rendered Once
Capture Webcam's Image with Ruby
Can't Find a Route with an Underscore or Doesn't Treat It Properly
Count Iteration on the Enumerable Cycle
What Is the Fastest Way to Sort a Hash
Override a Method Inside a Gem from Another Gem
Calling a Method of a Ruby Singleton Without the Reference of 'Instance'
Fresh Rails App Defaulting to Postgres Instead of SQLite3
Convert String to Datetime Ruby on Rails
Why Doesn't Puts() Print in a Single Line
Pass Arguments by Reference to a Block with the Splat Operator
Obfuscating Rails App on Mri Ruby/Jruby for a Enterprise Customer
Incompatible Character Encoding in Rails - How to Just Fail/Skip Sensibly
How to 'Join' an Array Adding to the Beginning of the Resulting String the First Character to Join
Bundler::Rubyversionmismatch: Your Ruby Version Is 1.9.3, But Your Gemfile Specified 2.0.0