It's a good idea to install Ruby gems via "emerge", however, it's reality that many prefer to do it directly with "gem". Gems may contain Ruby scripts that go to /usr/bin - and that's when it can get messy. Let's assume you eselect ruby18 and install the rake gem. This gem installs the rake script which gets the shebang /usr/bin/ruby18. Now eselect ruby19 and install the same gem there. The rake script will be overwritten with shebang /usr/bin/ruby19. The attached patch is a workaround for this. When switching to another Ruby profile, the shebang of all scripts generated by RubyGems is altered from the versioned "rubyNN" to "ruby" (the symlink). Reproducible: Always Steps to Reproduce: I'm aware that such a patch is not an ideal solution. I'm also asking upstream whether there's a chance to have RubyGems NOT expand /usr/bin/ruby if it is a symlink like ruby -> ruby18. I'll add a comment once I have an answer.
Created attachment 190449 [details, diff] shebang patch for ruby.eselect
I got some interesting input from upstream and can write a patch now that honors both Gentoo's as well as Ruby's paradigms. So let me close this bug, I'll submit the patch as soon as it's written and tested.