Where do gems install?

Ruby on-RailsRubygems

Ruby on-Rails Problem Overview


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.

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

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.

Solution 2 - Ruby on-Rails

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'

Solution 3 - Ruby on-Rails

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

Solution 4 - Ruby on-Rails

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTripView Question on Stackoverflow
Solution 1 - Ruby on-RailstheIVView Answer on Stackoverflow
Solution 2 - Ruby on-RailsdrinorView Answer on Stackoverflow
Solution 3 - Ruby on-RailsBian JiapingView Answer on Stackoverflow
Solution 4 - Ruby on-RailskikitoView Answer on Stackoverflow