100

I know that when using gem install, the gem will be stored under /home/username/.rvm/gems/, under which gemset the gem was installed.

But if I use Bundler and specify the gem in the Gemfile, when I run bundle install, where will those gems be stored? And what if I already installed the gem using gem install, if I run bundle install, will it use the previous gem installed using gem install?

Nakilon
  • 34,866
  • 14
  • 107
  • 142
gerky
  • 6,267
  • 11
  • 55
  • 82

5 Answers5

90

If you want to find out where a particular gem is stored you can run bundle info <gem-name>. For example:

user@host$ bundle info rake
/var/bundle/ruby/2.1.0/gems/rake-10.4.2

For older versions of rake, the command could be bundle show <gem_name>.

Obromios
  • 15,408
  • 15
  • 72
  • 127
James Kingsbery
  • 7,298
  • 2
  • 38
  • 67
67

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.

Frederick Cheung
  • 83,189
  • 8
  • 152
  • 174
  • You can also specify the installation path as a parameter to [bundle install](http://gembundler.com/v1.2/bundle_install.html): `$ bundle install --path vendor/bundle` – webwurst Feb 16 '13 at 23:19
  • 7
    I didn't understand the answer, so what is the default installation path for bundle install? If it's used in development. – Sida Zhou Nov 03 '14 at 19:40
  • in development, it will install them in the same place as just doing `gem install` would (which depends on GEM_HOME, GEM_PATH etc) – Frederick Cheung Nov 03 '14 at 20:33
  • So, by default it will install all gems in a system-wide (as opposed to project-specific) location? – David Dec 01 '17 at 07:20
  • @David it could be system wide or a user specific location, depending on rubygems configuration. – Frederick Cheung Dec 03 '17 at 07:05
9

I use bundle config path to see where gems are stored.

bartonstanley
  • 1,167
  • 12
  • 25
3

Here /usr/local/lib/ruby/gems/2.1.0/gems/ and here: /usr/local/lib/ruby/gems/2.1.0/bundler/gems/.

Robert Reiz
  • 4,243
  • 2
  • 30
  • 43
2

Note that gems are also installed into the bundle folder within your "Gem Path" (see: bundle env). This happens, for example, with gems installed from git:

gem 'my-gem', git: "https://github.com/x/y.git"

I assume this is so that custom installations don't conflict with installations from a gem server.

thisismydesign
  • 21,553
  • 9
  • 123
  • 126