If I do gem list rack-cache in rails command prompt then it shows no gem with that name but if I do bundle show rack-cache then it gives me the path like /vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2 of where the gem is stored.
I didn’t understood this behavior because if the gem is present in the path with the latter command then why its not showing when I gives gem list rack-cache command.
What’s the difference.
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 railsrubygems 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 installis 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-cachethroughgem installyou’ll also see it ingem list.