ruby gems under rvm on Ubuntu (failing to) install in the wrong location - ruby

I'm running Ubuntu 10.04 and originally installed ruby 1.9.1 (from source). I've just decided to try out ruby 1.9.2 and rails 3, and it seemed like a good time to use rvm to deal with the multiple ruby installs and gemsets.
rvm installed and seems to be working, I installed ruby 1.9.2 in rvm and made that my default ruby. However, every time I try to install a gem under ruby 1.9.2 I see this error.
mark#Steve-Austins-Penguin:~$ gem install haml
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /home/mark/.gem/specs
gem environment returns:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/mark/.rvm/gems/ruby-1.9.2-p0
- RUBY EXECUTABLE: /home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
- EXECUTABLE DIRECTORY: /home/mark/.rvm/gems/ruby-1.9.2-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/mark/.rvm/gems/ruby-1.9.2-p0
- /home/mark/.rvm/gems/ruby-1.9.2-p0#global
<snip>
But if the correct installation, ruby and gem paths are showing here why is ruby trying to install gems to /home/mark/.gem? All the variables and paths shown by env look right, and I can't find a .gemrc file anywhere on my system that might contain conflicting path settings.
So I guess my question is what might be causing rubygems to attempt to install to /home/mark/.gems instead of the correct paths set by rvm?
In response to the question below:
mark#Steve-Austins-Penguin:~$ echo $PATH
/home/mark/.rvm/gems/ruby-1.9.2-p0/bin:/home/mark/.rvm/gems/ruby-1.9.2-p0#global/bin:/home/mark/.rvm/rubies/ruby-1.9.2-p0/bin:/home/mark/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
mark#Steve-Austins-Penguin:~$ which gem
/home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/gem
mark#Steve-Austins-Penguin:~$ rvm list
rvm rubies
ruby-1.8.7-p302 [ x86_64 ]
=> ruby-1.9.2-p0 [ x86_64 ]
mark#Steve-Austins-Penguin:~$ env
rvm_gemsets_path=/home/mark/.rvm/gemsets
MANPATH=:/home/mark/.rvm/man
rvm_scripts_path=/home/mark/.rvm/scripts
rvm_bin_path=/home/mark/.rvm/bin
GEM_HOME=/home/mark/.rvm/gems/ruby-1.9.2-p0
rvm_patchsets_path=/home/mark/.rvm/patchsets
SHELL=/bin/bash
IRBRC=/home/mark/.rvm/rubies/ruby-1.9.2-p0/.irbrc
rvm_patches_path=/home/mark/.rvm/patches
MY_RUBY_HOME=/home/mark/.rvm/rubies/ruby-1.9.2-p0
rvm_selfcontained=1
USER=mark
__shell_array_start=0
rvm_gems_cache_path=/home/mark/.rvm/gems/cache
rvm_config_path=/home/mark/.rvm/config
rvm_path=/home/mark/.rvm
USERNAME=mark
rvm_gemset_separator=#
rvm_ruby_args=
rvm_rubies_path=/home/mark/.rvm/rubies
PWD=/home/mark
rvm_hooks_path=/home/mark/.rvm/hooks
rvm_version=1.0.1
rvm_src_path=/home/mark/.rvm/src
HOME=/home/mark
rvm_gems_path=/home/mark/.rvm/gems
rvm_ruby_string=ruby-1.9.2-p0
BUNDLE_PATH=/home/mark/.rvm/gems/ruby-1.9.2-p0
rvm_tmp_path=/home/mark/.rvm/tmp
LOGNAME=mark
GEM_PATH=/home/mark/.rvm/gems/ruby-1.9.2-p0:/home/mark/.rvm/gems/ruby-1.9.2-p0#global
rvm_action=list
rvm_log_path=/home/mark/.rvm/log
rvm_interactive=1
RUBY_VERSION=ruby-1.9.2-p0
rvm_archives_path=/home/mark/.rvm/archives
rvm_repo_path=/home/mark/.rvm/repos
_=/usr/bin/env
Note that I've edited down the response from env slightly - simply to keep the size of this post under control - by removing all the entries relating to X, GNOME and SSH.

Following up the backtrace from running gem install -V --backtrace --debug haml (thanks zzzhc) and taking a closer look at the /home/mark/.gem directory I found that there were no gems installed there, just gemspec files and gem source files. In the spirit of experimentation I deleted /home/mark/.gem and re ran the gem install command and suddenly it was working. And that it had recreated /home/mark/.gem containing gemspecs for the gems I'd just installed.
It's clear now that I'd misinterpreted the error message in the original question; rubygems didn't fail while trying to install gems to /home/mark/.gem, it was simply using that directory as a temporary store for the gemspecs of newly downloaded gems about to be installed. Before installing rvm I'd been installing gems onto the system using sudo gem install... which would have created the /home/mark/.gem directory with root permissions. So rubygems run without sudo was unable to access the temp directory to store gemspecs in and was aborting before it could install the gems. Doh!

Another way is type which gem after getting into the ruby version. You will get something like this - /home/username/.rvm/rubies/ruby-1.9.2-p180/bin/gem. Now just type sudo /home/username/.rvm/rubies/ruby-1.9.2-p180/bin/gem install gem_name.
Specifying the complete path and adding sudo work fine.

check the first line of /home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/gem and look at http://yehudakatz.com/2010/08/24/a-tale-of-abort-traps-or-always-question-your-assumptions/

Related

Removed rvm but gem env still says my INSTALLATION DIRECTORY is .rvm/gems which doesn't exist

I am trying to remove RVM from my desktop (which used ruby 1.9), so I can use vanilla ruby 2.3, which works on my formatted laptop. So I did
rvm implode
That got rid of the ~/.rvm dir and I soon got ruby --version to say it uses 2.3.1 etc. However when I do gem env, I still get:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- RUBY VERSION: 1.9.3 (2015-06-17 patchlevel 551) [java]
- INSTALLATION DIRECTORY: /home/foo/.rvm/gems/ruby-1.9.3-p551
- RUBY EXECUTABLE: /usr/share/jruby/bin/jruby
- EXECUTABLE DIRECTORY: /home/foo/.rvm/gems/ruby-1.9.3-p551/bin
- SPEC CACHE DIRECTORY: /home/foo/.gem/specs
Note that the /home/foo/.gem/ directory doesn't exist any more! How can I fix gem env? I am using Fedora 23 (soon 24) and I want to reset it to the system's default.
I tried a bunch of things (like reinstalling rubygems) with no luck.

Track down and upgrade a hard to find ruby gem

While running vagrant, which is presumably written in Ruby, I got the following error (vagrant --help produces that same error message):
$ vagrant plugin install vagrant-hostmanager
Vagrant experienced a version conflict with some installed plugins!
This usually happens if you recently upgraded Vagrant. As part of the
upgrade process, some existing plugins are no longer compatible with
this version of Vagrant. The recommended way to fix this is to remove
your existing plugins and reinstall them one-by-one. To remove all
plugins:
rm -r ~/.vagrant.d/plugins.json ~/.vagrant.d/gems
Note if you have an alternate VAGRANT_HOME environmental variable
set, the folders above will be in that directory rather than your
user's home directory.
The error message is shown below:
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
vagrant (= 1.8.4) was resolved to 1.8.4, which depends on
bundler (~> 1.12.5)
Current Bundler version:
bundler (1.11.2)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
After checking that ~/.vagrant.d/gems contains nothing except ruby, I sudo gem update and check bundler --version: 1.12.5. Bundler has been updated. Unfortunately, I get the same error on the next run. Vagrant seems to be importing gems from a different location than where gem update saves them. After some googling, I discover gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.3.0
- USER INSTALLATION DIRECTORY: /home/dan/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /usr/bin/ruby2.3
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /home/dan/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.3.0
- /home/dan/.gem/ruby/2.3.0
- /usr/lib/x86_64-linux-gnu/rubygems-integration/2.3.0
- /usr/share/rubygems-integration/2.3.0
- /usr/share/rubygems-integration/all
Looking in the gems directories of the GEM PATHS list, I only see a bundler-1.12.5 gem. I know that bundler 1.11.2 must exist somewhere on my system if Vagrant is loading it, so locate bundler-1.11.2:
/usr/share/rubygems-integration/all/specifications/bundler-1.11.2.gemspec
What is that gemspec? Do I have to specify its location somehow when I am upgrading the bundler gem, in order to keep some metadata up to date?
I did just recently update vagrant, using apt-get, from a more recent Debian package than the one in my system's package repository.

How do I ensure ruby gems are installed in right place to be executed by bundler?

I seem to be constantly having problems with getting the gems in the right place (and not needing to use sudo when installing them.)
To address the sudo issue, I installed rbenv and then use that to install ruby 2.1.0 so that I had a separate one from Mac OSX system.
Then I installed bundler. But when I install gems from a Gemfile with bundler, I cannot find them.
Between all the steps I have taken, such as adding lines to my .bash_profile and so forth, I have the following, but really just want a clear, straightforward way to manage gems and their local execution:
gem env :
Edit: I removed everything and reset PATH -- still didn't fix anything, but you can see that gems are installed in one directory but when I call the executable, the command cannot be found:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [universal.x86_64-darwin13]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-13
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/fongster/.gem/ruby/2.0.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
Here is what happens when I want to run, say shotgun:
bash-3.2$ shotgun
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:into_specs': Could not find 'shotgun' (>= 0) among 12 total gem(s) (Gem::LoadError)
Can someone point me to simple, straightforward directdions for ruby gem management on OSX so that:
I don't need to use sudo to install gems
I can use bundler to install from a Gemfile for a given project
Those gems and their executables (shotgun, restclient, sass) can just be executed
My local environment based on this set up 'just works' in heroku?
I don't need to type bundle exec when I need to do stuff
Also some clarity on whether I need to always go to a bash shell (currently, I have been using exec bash to get my shell working).
EDIT: Following the steps below and have this response upon bundle:
Errno::EEXIST: File exists # dir_s_mkdir - /Users/fongster/.rbenv/shims/gem
An error occurred while installing backports (3.6.3), and Bundler cannot
continue.
Make sure that `gem install backports -v '3.6.3'` succeeds before bundling.
Use rbenv-gemset. It works great and meets all your requirements. I have been using it for 2 years and have not had any problems. No issues with Heroku.
Here's my process for setting up a new Ruby project:
1. Create directory (or Rails app in new directory)
2. cd directory
3. Set ruby version: Use 2.1.0 or another version
rbenv local 2.1.0
4. Set gemset: replace app-name with the name of the app
echo app-name > .rbenv-gemsets
5. Check gemset. Should be app-name global:
rbenv gemset active
6. rbenv rehash
7. Create Gemfile
8. gem install bundler
9. bundle
When it does not work as expected, do rbenv rehash.
You should never need to install gems using sudo.
Regarding your shell, that could be causing problems. If a regular terminal doesn't work then there is probably another issue.
Since the issue seems related to your shell and PATH, here's my .bash_profile
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH=/usr/local/bin:$PATH
eval "$(rbenv init -)"
You may want to try replacing your .bash_profile with the above, or create a new user and see if the issue disappears.
From a clean start
You do not have to do anything apart from the plain steps stated on the Bundler home page:
Do NOT use sudo bundle ...
Do NOT change anything to your PATH
Do not touch any ~/.file
Copy require 'bundler/setup' at the top of your first application file
DO use bundle exec in front of all your Bundler-managed "binaries"
Everything just works using the nice defaults for a developer workstation. When you want to go further like running multiples Rubies side by side or deploying to prod or are fed up with typing bundle exec (which you should alias to bex using alias bex='bundle exec') you can then Read The Full Manual, type bundle install --binstubs and install one of the Rubymongers (RBEnv, RVM).
In your specific situation
I would restart from scratch:
uninstall RBEnv (rm -rf ~/.rbenv and delete rbenv mentions in grep rbenv ~/.bashrc ~/.bash_profile ~/.zshrc /etc/profile /etc/profile.d/*)
uninstall Bundler

Can't install or update gems: YAML parse error

I am trying to install Compass and Jekyll, but the gem commands fail:
$ gem update
/usr/lib/ruby/1.9.1/psych.rb:154:in `parse': (<unknown>): couldn't parse YAML at line 2 column 0 (Psych::SyntaxError)
From googling, I see that Ruby has updated it's YAML parser and that gems need to update their config/boot.rb file, but that doesn't help me unless I fork every gem that I install.
Here is my .gemrc, it is the only place where I could have screwed something up:
gemhome: /home/dan/.gems
gempath:
- /home/dan/.gems
Ruby version: ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux], installed using apt-get on Ubuntu.
What do I have to do to start installing ruby gems? I know almost nothing about ruby, I just want to install some software that is distributed as gems.
update
Looking at my question, I see that the ruby version in the error message and ruby --version are different. How do the ruby command and the gem command decide which version to use? Does it matter that they are different? update: I now have only ruby 1.9.3. The problem must be with my .gemrc
update
Removing my .gemrc and installing as root works. What is wrong with my .gemrc?
The Yaml syntax is valid. (See http://yamllint.com/).
However, the problem lies in the variables names gemhome and gempath - they are supposed to be GEM_PATH and GEM_HOME.
See What's the difference between GEM_HOME and GEM_PATH? for more info.
You could type in gem env before and after removing the .gemrc file and you should see a difference in the gem path.
The gem configuration file is not really need in your case since your GEM_PATH/ GEM_HOME don't need to be changed from the defaults...
To install gems below your home directory, use the --user-install parameter:
gem install <gem> --user-install
Mentioned in the ruby gem FAQ. A similar question suggest using RVM to manage gems. It installs gems below the home dir.

How to find where gem files are installed

I can finds gems that are installed using gem list, but it doesn't show me where the gems are installed.
How can I find where the gems are, and how can I know before installing a gem where it will be installed?
Use gem environment to find out about your gem environment:
RubyGems Environment:
- RUBYGEMS VERSION: 2.1.5
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-darwin12.4.0]
- INSTALLATION DIRECTORY: /Users/ttm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0
- RUBY EXECUTABLE: /Users/ttm/.rbenv/versions/2.0.0-p247/bin/ruby
- EXECUTABLE DIRECTORY: /Users/ttm/.rbenv/versions/2.0.0-p247/bin
- SPEC CACHE DIRECTORY: /Users/ttm/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/ttm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0
- /Users/ttm/.gem/ruby/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/ttm/.rbenv/versions/2.0.0-p247/bin
- /Users/ttm/.rbenv/libexec
- /Users/ttm/.rbenv/plugins/ruby-build/bin
- /Users/ttm/perl5/perlbrew/bin
- /Users/ttm/perl5/perlbrew/perls/perl-5.18.1/bin
- /Users/ttm/.pyenv/shims
- /Users/ttm/.pyenv/bin
- /Users/ttm/.rbenv/shims
- /Users/ttm/.rbenv/bin
- /Users/ttm/bin
- /usr/local/mysql-5.6.12-osx10.7-x86_64/bin
- /Users/ttm/libsmi/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/bin
Notice the two sections for:
INSTALLATION DIRECTORY
GEM PATHS
I found it useful to get a location of the library file with:
gem which *gemname*
After installing the gems, if you want to know where a particular gem is. Try typing:
gem list
You will be able to see the list of gems you have installed. Now use bundle show and name the gem you want to know the path for, like this:
bundle show <gemName>
Or (as of younger versions of bundler):
bundle info <gemName>
To complete other answers, the gem-path gem can find the installation path of a particular gem.
Installation:
gem install gem-path
Usage:
gem path rails
=> /home/cbliard/.rvm/gems/ruby-2.1.5/gems/rails-4.0.13
gem path rails '< 4'
=> /home/cbliard/.rvm/gems/ruby-2.1.5/gems/rails-3.2.21
This is really handy as you can use it to grep or edit files:
grep -R 'Internal server error' "$(gem path thin)"
subl "$(gem path thin)"
You can check it from your command prompt by running gem help commands and then selecting the proper command:
kirti#kirti-Aspire-5733Z:~$ gem help commands
GEM commands are:
build Build a gem from a gemspec
cert Manage RubyGems certificates and signing settings
check Check a gem repository for added or missing files
cleanup Clean up old versions of installed gems in the local
repository
contents Display the contents of the installed gems
dependency Show the dependencies of an installed gem
environment Display information about the RubyGems environment
fetch Download a gem and place it in the current directory
generate_index Generates the index files for a gem server directory
help Provide help on the 'gem' command
install Install a gem into the local repository
list Display gems whose name starts with STRING
lock Generate a lockdown list of gems
mirror Mirror all gem files (requires rubygems-mirror)
outdated Display all gems that need updates
owner Manage gem owners on RubyGems.org.
pristine Restores installed gems to pristine condition from
files located in the gem cache
push Push a gem up to RubyGems.org
query Query gem information in local or remote repositories
rdoc Generates RDoc for pre-installed gems
regenerate_binstubs Re run generation of executable wrappers for gems.
search Display all gems whose name contains STRING
server Documentation and gem repository HTTP server
sources Manage the sources and cache file RubyGems uses to
search for gems
specification Display gem specification (in yaml)
stale List gems along with access times
uninstall Uninstall gems from the local repository
unpack Unpack an installed gem to the current directory
update Update installed gems to the latest version
which Find the location of a library file you can require
yank Remove a specific gem version release from
RubyGems.org
For help on a particular command, use 'gem help COMMAND'.
Commands may be abbreviated, so long as they are unambiguous.
e.g. 'gem i rake' is short for 'gem install rake'.
kirti#kirti-Aspire-5733Z:~$
Now from the above I can see the command environment is helpful. So I would do:
kirti#kirti-Aspire-5733Z:~$ gem help environment
Usage: gem environment [arg] [options]
Common Options:
-h, --help Get help on this command
-V, --[no-]verbose Set the verbose level of output
-q, --quiet Silence commands
--config-file FILE Use this config file instead of default
--backtrace Show stack backtrace on errors
--debug Turn on Ruby debugging
Arguments:
packageversion display the package version
gemdir display the path where gems are installed
gempath display path used to search for gems
version display the gem format version
remotesources display the remote gem servers
platform display the supported gem platforms
<omitted> display everything
Summary:
Display information about the RubyGems environment
Description:
The RubyGems environment can be controlled through command line arguments,
gemrc files, environment variables and built-in defaults.
Command line argument defaults and some RubyGems defaults can be set in a
~/.gemrc file for individual users and a /etc/gemrc for all users. These
files are YAML files with the following YAML keys:
:sources: A YAML array of remote gem repositories to install gems from
:verbose: Verbosity of the gem command. false, true, and :really are the
levels
:update_sources: Enable/disable automatic updating of repository metadata
:backtrace: Print backtrace when RubyGems encounters an error
:gempath: The paths in which to look for gems
:disable_default_gem_server: Force specification of gem server host on
push
<gem_command>: A string containing arguments for the specified gem command
Example:
:verbose: false
install: --no-wrappers
update: --no-wrappers
:disable_default_gem_server: true
RubyGems' default local repository can be overridden with the GEM_PATH and
GEM_HOME environment variables. GEM_HOME sets the default repository to
install into. GEM_PATH allows multiple local repositories to be searched for
gems.
If you are behind a proxy server, RubyGems uses the HTTP_PROXY,
HTTP_PROXY_USER and HTTP_PROXY_PASS environment variables to discover the
proxy server.
If you would like to push gems to a private gem server the RUBYGEMS_HOST
environment variable can be set to the URI for that server.
If you are packaging RubyGems all of RubyGems' defaults are in
lib/rubygems/defaults.rb. You may override these in
lib/rubygems/defaults/operating_system.rb
kirti#kirti-Aspire-5733Z:~$
Finally to show you what you asked, I would do:
kirti#kirti-Aspire-5733Z:~$ gem environment gemdir
/home/kirti/.rvm/gems/ruby-2.0.0-p0
kirti#kirti-Aspire-5733Z:~$ gem environment gempath
/home/kirti/.rvm/gems/ruby-2.0.0-p0:/home/kirti/.rvm/gems/ruby-2.0.0-p0#global
kirti#kirti-Aspire-5733Z:~$
You can trick gem open into displaying the gem path:
VISUAL=echo gem open gem-name
Example:
VISUAL=echo gem open rails
=> /usr/local/opt/asdf/installs/ruby/2.4.3/lib/ruby/gems/2.4.0/gems/rails-5.1.4
It just works, and no third party gem is necessary.
gem env works just like gem environment. Saves some typing.
# gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [i686-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.0.0
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.0.0
- /root/.gem/ruby/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
The gem env lists where gems can be installed, but this can be 10 or more locations. If you want to know where a particular gem is installed, you can execute:
gem list -d <gemname>
Example output:
tilt (2.0.9)
Author: Ryan Tomayko
Homepage: http://github.com/rtomayko/tilt/
License: MIT
Installed at: /opt/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0
Generic interface to multiple Ruby template engines
if you are using rvm tool you can run this command to print gem path:
rvm gemdir
OR
echo $GEM_HOME
This works and gives you the installed at path for each gem. This super helpful when trying to do multi-stage docker builds.. You can copy in the specific directory post-bundle install.
bash-4.4# gem list -d
Output::
aasm (5.0.6)
Authors: Thorsten Boettger, Anil Maurya
Homepage: https://github.com/aasm/aasm
License: MIT
Installed at: /usr/local/bundle
State machine mixin for Ruby objects
One can go to rails console and do
Gem.bin_path('<gem-name>', '<gem-executable-name>')
It returns exact path to the gem file executable.
Ref: https://www.rubydoc.info/github/rubygems/rubygems/Gem.bin_path

Resources