Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do gems install?

I'm trying to edit one of the gem's config files and I can't find it. I'm not sure how I did this in the past.

like image 269
Trip Avatar asked Aug 04 '10 19:08

Trip


People also ask

Where are gem files installed?

When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9.

Where are gem bundles installed?

This location depends on how rubygems itself is configured. 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.

How does gem install work?

What does gem install do? gem install , in its simplest form, does something kind of like this. It grabs the gem and puts its files into a special directory on your system. You can see where gem install will install your gems if you run gem environment (look for the INSTALLATION DIRECTORY: line):

How do you check if a gem is installed?

Since your goal is to verify a gem is installed with the correct version, use gem list . You can limit to the specific gem by using gem list data_mapper . To verify that it's installed and working, you'll have to try to require the gem and then use it in your code.


4 Answers

Look at your gem environment.

In a terminal run gem env

You should see an entry INSTALLATION DIRECTORY, but there is also GEM PATHS which is where it's loading all your gems from in your current environment.

like image 86
theIV Avatar answered Oct 12 '22 18:10

theIV


Rvm

$ rvm gemdir

Or you can check:

echo $GEM_HOME

Bundler

$ bundle show --paths

For specific gem:

$ bundle show 'gem_name'

Gem

$ gem env

For specific gem:

$ gem which 'gem_name'
like image 40
drinor Avatar answered Oct 12 '22 18:10

drinor


To see the default installation directory, run

gem env gemdir

If you want to change the default installation directory (for example, to ~/.gem/ruby/2.1.0), add this line to ~/.bashrc

export GEM_HOME=~/.gem/ruby/2.1.0

And you also need to make sure ~/.gem/ruby/2.1.0/bin is in your PATH environment variable to use the commands provided by gem packages. If not, add this line to ~/.bashrc

export PATH=$PATH:~/.gem/ruby/2.1.0/bin

like image 40
Bian Jiaping Avatar answered Oct 12 '22 19:10

Bian Jiaping


If you are editing the gem's installed files, then the gem wasn't implemented correctly, or you are not modifying it correctly.

Proper gems are usually configured:

  • via an initializer script on config/initializers
  • via monkeypatching on lib
  • via generators provided by the gem itself. These tend to generate lots of files, but they usually have a "initialize" or "install" option for setting up the gem.
like image 30
kikito Avatar answered Oct 12 '22 19:10

kikito