[Rubygems-developers] Can anyone shed a little light on executable gems for me?

Eric Hodel drbrain at segment7.net
Sat Jan 5 04:30:21 EST 2008

On Dec 28, 2007, at 24:33 AM, michael greenly wrote:

> It seems to me that something has changed quite a bit about how  
> executable gems are handled in the last few versions?
> In the past there was a $GEM_HOME/bin directory but it doesn't seem  
> to be there any more?  Instead it seems the executable files for  
> installed gems end up in the same place that the gem command exits?   
> Is this right?  Or am I off base on this?

When installing a gem, if the install dir is the same as the default  
gem dir, the stub goes where `gem` goes.  If the install dir is  
different, it goes in $GEM_HOME/bin.

> The reason I ask is I'm left wondering how best to separate a Ruby  
> 1.8 environment from a Ruby 1.9 environment so that they can each  
> have a for example a 'rails' gem installed and work in both  
> environments at the same time but with separate gems?

RubyGems 1.0.1 has the --format-executable option to `gem install`, so  
if you have ruby18 and ruby19, gems installed via ruby18 will have 18  
appended to their bin stubs, and gems installed via ruby19 will have  
19 appended to their bin stubs.

> There seemed to be a really straight forward solution prior to this  
> change?  If the executable files for gems were installed in  
> $GEM_HOME/bin then simply installing Ruby using ./configure -- 
> program-suffix=1.8 or --program-suffix= 1.9 like all the linux  
> distributions do anyway would keep everything from overlapping.   
> Then it would be a simple(maybe?) matter of hacking in a "gem run  
> <executablegem>" command.  This then would allow the end user to do  
> " gem1.8 run rails" or "gem1.9 run rails" etc...

Add these lines to ~/.gemrc:

install: --format-executable
update: --format-executable

then you will get rails1.8 and rails1.9.

More information about the Rubygems-developers mailing list