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?

2
  • 27
    bundle show <gemname>
    – Chowlett
    Jul 24, 2012 at 16:17
  • 5
    Bundler now says "[DEPRECATED] use bundle info <gemname> instead of bundle show <gemname>".
    – nyanpasu64
    Jan 2, 2021 at 9:49

5 Answers 5

91

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>.

2
  • Does this imply that all gems are just installed on your ruby?
    – Jwan622
    Apr 7, 2016 at 22:34
  • 1
    Note that bundle show GEM is deprecated in favor of bundle info GEM
    – Greg
    Jan 12, 2020 at 9:31
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.

5
  • You can also specify the installation path as a parameter to bundle install: $ bundle install --path vendor/bundle
    – webwurst
    Feb 16, 2013 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 3, 2014 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) Nov 3, 2014 at 20:33
  • So, by default it will install all gems in a system-wide (as opposed to project-specific) location?
    – David
    Dec 1, 2017 at 7:20
  • @David it could be system wide or a user specific location, depending on rubygems configuration. Dec 3, 2017 at 7:05
10

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

3

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

2
  • 4
    I'd imagine this only applies to certain operating systems Sep 17, 2015 at 19:53
  • 6
    Do you know how bundler decides which gems go in which directory? Nov 13, 2015 at 18:10
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.