postmodern / chruby

Changes the current Ruby
MIT License
2.85k stars 190 forks source link

gem executables will not run #455

Open jemiller1963 opened 3 years ago

jemiller1963 commented 3 years ago

I am having an issue with gem executables.

I installed Ruby with Chruby but I am having issues with installing Foreman. I am getting the message:

[chat-stimulus] gem install foreman 
WARNING:  You don't have /Users/jem/.gem/ruby/2.6.0/bin in your PATH,
      gem executables will not run.
Successfully installed foreman-0.87.2
1 gem installed

I put the output from my terminal into this gist. If you need more info, let me know and I will post.

https://gist.github.com/jemiller1963/25e45c4fe183cd9382a77f9073265fb7

Thanks!

postmodern commented 2 years ago

What does which foreman return? Definitely looks like foreman was installed, but rubygems is complaining that the .gem/ruby/2.6.0/bin directory ins't in PATH (2.6.0 is the Ruby ABI version for 2.6.6p146, but chruby uses the exact RUBY_VERSION string for the GEM_HOME).

cayleyh commented 9 months ago

I'm saw this as well, so can add more details on what I observed:

After installing foreman and seeing this warning, which foreman returns foreman not found.

which gem returned ~/.rubies/ruby-2.6.10/bin/gem

~/.gem/ruby/ contained 2 directories:

The difference for me was that I had installed using the --user-install flag (set via a previous .gemrc configuration I had of course forgotten about...)

chruby was correctly changing GEM_PATH and GEM_HOME, but these do not change the user_gemhome that gem uses internally for resolving user installed gems. As far as I can tell, that is always set to the ruby ABI version in ~/.gem/ruby, and I didn't find a separate environment var that allowed it to be overwritten.

To sum up:

chruby behaviour could potentially be modified to add both of these to the path automatically when setting a ruby version to use. This would allow packages installed either way (gem install or gem install --user-install) to work as expected.