# RubyGems and ENV vars?

**URL:** <https://www.ruby-forum.com/t/rubygems-and-env-vars/127780>\
**Category:** Ruby\
**Created:** [February 1, 2008, 8:50am UTC](https://www.ruby-forum.com/t/rubygems-and-env-vars/127780 "2008-02-01T08:50:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Une\_BSSSSvS\_ue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/2acd7d/32.png) [@Une\_BSSSSvS\_ue](https://www.ruby-forum.com/u/Une_BSSSSvS_ue)\
**Post date:** [February 1, 2008, 8:50am UTC](https://www.ruby-forum.com/t/rubygems-and-env-vars/127780/1 "2008-02-01T08:50:27Z")

</div>

I’m working (on Mac OS X) with two installed ruby (apart from Apple  
default one):

$ which ruby  
/opt/local/bin/ruby  
$ which ruby19  
/opt/local/bin/ruby19

(all of the Ruby-1.9.0-0 bins have a “19” suffix)

## when i try a simple script as :

#! /usr/bin/env ruby19  
require “appscript”  
include Appscript

## p app(‘Finder’).home.folders.get

## i get the following :

RubyMate r6354 running Ruby r1.9.0 (/opt/local/bin/ruby19)

> > > desktop.rb

## /opt/local/lib/ruby/site\_ruby/1.8/\_aem/aemreference.rb:15:in `new' : Not a four-char-code string. ( ArgumentError ) from /opt/local/lib/ruby/site_ruby/1.8/_aem/aemreference.rb:15:in`pack\_enum’ from /opt/local/lib/ruby/site\_ruby/1.8/\_aem/aemreference.rb:204:in `<class:PositionSpecifier>' from /opt/local/lib/ruby/site_ruby/1.8/_aem/aemreference.rb:193:in`module:AEMReference’ from /opt/local/lib/ruby/site\_ruby/1.8/\_aem/aemreference.rb:44:in `<top (required)>' from /opt/local/lib/ruby/site_ruby/1.8/_aem/codecs.rb:8:in`require’ from /opt/local/lib/ruby/site\_ruby/1.8/\_aem/codecs.rb:8:in `<top (required)>' from /opt/local/lib/ruby/site_ruby/1.8/aem.rb:14:in`require’ from /opt/local/lib/ruby/site\_ruby/1.8/aem.rb:14:in `<module:AEM>' from /opt/local/lib/ruby/site_ruby/1.8/aem.rb:10:in`\<top (required)\>’ from /opt/local/lib/ruby/site\_ruby/1.8/appscript.rb:13:in `require' from /opt/local/lib/ruby/site_ruby/1.8/appscript.rb:13:in`module:Appscript’ from /opt/local/lib/ruby/site\_ruby/1.8/appscript.rb:7:in `<top (required)>' from /Users/yt/work/Ruby19/rb-appscript/Finder/desktop.rb:4:in`require’ from /Users/yt/work/Ruby19/rb-appscript/Finder/desktop.rb:4:in `’

then, ruby19 is looking into “/opt/local/lib/ruby/site\_ruby/1.8”

i think this is due to my environment variables for Rubygems :

$ echo $RUBYOPT  
rubygems  
$ echo $GEM\_HOME  
/opt/local/lib/ruby/gems/1.8  
$ echo $RUBYLIB  
/opt/local/lib/ruby/:/opt/local/lib/ruby/site\_ruby/1.8  
$ echo $RUBYGEMS  
/opt/local/lib/ruby/site\_ruby/1.8

is there a way to setup those environment variables to get ruby and  
ruby19 working with gems without switching an environment variable ?

---

<div class="post-metadata">

**Author:** ![Une\_BSSSSvS\_ue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/2acd7d/32.png) [@Une\_BSSSSvS\_ue](https://www.ruby-forum.com/u/Une_BSSSSvS_ue)\
**Post date:** [February 1, 2008, 2:55pm UTC](https://www.ruby-forum.com/t/rubygems-and-env-vars/127780/2 "2008-02-01T14:55:21Z")

</div>

On Feb 1, 2008, at 1:49 AM, Une Bévue wrote:

> when i try a simple script as :  
> RubyMate r6354 running Ruby r1.9.0 (/opt/local/bin/ruby19)  
> Your question is about TextMate, not Ruby. It’s covered in TextMate’s  
> manual. See the “Important” paragraph in this section:

[http://macromates.com/textmate/manual/shell\_commands#search\_path](http://macromates.com/textmate/manual/shell_commands#search_path)

Hope that helps.

James Edward G. II

---

<div class="post-metadata">

**Author:** ![Une\_BSSSSvS\_ue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/2acd7d/32.png) [@Une\_BSSSSvS\_ue](https://www.ruby-forum.com/u/Une_BSSSSvS_ue)\
**Post date:** [February 1, 2008, 5:55pm UTC](https://www.ruby-forum.com/t/rubygems-and-env-vars/127780/3 "2008-02-01T17:55:38Z")

</div>

James G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Your question is about TextMate, not Ruby.

Sorry but i disagree )))

because, “experimen"aly” I got the same error from Terminal.app :

* * *

## ~/work/Ruby19/rb-appscript/Finder%\> ruby19 desktop.rb /opt/local/lib/ruby/site\_ruby/1.8/\_aem/aemreference.rb:15:in `new': Not a four-char-code string. (ArgumentError) from /opt/local/lib/ruby/site_ruby/1.8/_aem/aemreference.rb:15:in `pack\_enum’ from /opt/local/lib/ruby/site\_ruby/1.8/\_aem/aemreference.rb:204:in `<class:PositionSpecifier>' from /opt/local/lib/ruby/site_ruby/1.8/_aem/aemreference.rb:193:in `module:AEMReference’ from /opt/local/lib/ruby/site\_ruby/1.8/\_aem/aemreference.rb:44:in `<top (required)>' from /opt/local/lib/ruby/site_ruby/1.8/_aem/codecs.rb:8:in `require’ from /opt/local/lib/ruby/site\_ruby/1.8/\_aem/codecs.rb:8:in `<top (required)>' from /opt/local/lib/ruby/site_ruby/1.8/aem.rb:14:in `require’ from /opt/local/lib/ruby/site\_ruby/1.8/aem.rb:14:in `<module:AEM>' from /opt/local/lib/ruby/site_ruby/1.8/aem.rb:10:in `\<top (required)\>’ from /opt/local/lib/ruby/site\_ruby/1.8/appscript.rb:13:in `require' from /opt/local/lib/ruby/site_ruby/1.8/appscript.rb:13:in `module:Appscript’ from /opt/local/lib/ruby/site\_ruby/1.8/appscript.rb:7:in `<top (required)>' from desktop.rb:4:in `require’ from desktop.rb:4:in `’ ~/work/Ruby19/rb-appscript/Finder%\>

> It’s covered in TextMate’s  
> manual. See the “Important” paragraph in this section:
> 
> [http://macromates.com/textmate/manual/shell\_commands#search\_path](http://macromates.com/textmate/manual/shell_commands#search_path)

I knew that point, even if i forget it from time to time…

In fact my “environment.plist” reproduces (thanks to some ruby script)  
nearly all of my environment variables taken from Zsh ones.

The question is : are the values :

RUBYOPT === rubygems  
GEM\_HOME === /opt/local/lib/ruby/gems/1.8  
RUBYLIB === /opt/local/lib/ruby/:/opt/local/lib/ruby/site\_ruby/1.8  
RUBYGEMS === /opt/local/lib/ruby/site\_ruby/1.8

still needed with ruby 1.9, are they wrong ?  
even if they were correct with ruby 1.8…

i suspect there are wrong (at least RUBYGEMS) because I do have :

$ ls -al /opt/local/lib/ruby/site\_ruby  
drwxr-xr-x 39 root admin 1326 22 déc 07:33 1.8  
drwxr-xr-x 9 root admin 306 1 fév 08:11 1.9.0  
drwxr-xr-x 4 root admin 136 8 déc 10:54 bin  
drwxr-xr-x 6 root admin 204 8 déc 10:54 lib  
-rw-r–r-- 2 root admin 509 5 avr 2007 site-specific.rb

then, the error speaking about :  
“/opt/local/lib/ruby/site\_ruby/1.8/\_aem/aemreference.rb”

because this file isn’t the right one for ruby19, the right one being :  
“/opt/local/lib/ruby/site\_ruby/1.9.0/\_aem/aemreference.rb”

unfortunately i don’t know how RubyGems is able to find the correct gem,  
depending of the running ruby version ???

may be i’d have to change RUBYGEMS to :

RUBYGEMS === /opt/local/lib/ruby/site\_ruby

to let RubyGem choose by itself ???

---

<div class="post-metadata">

**Author:** ![Une\_BSSSSvS\_ue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/2acd7d/32.png) [@Une\_BSSSSvS\_ue](https://www.ruby-forum.com/u/Une_BSSSSvS_ue)\
**Post date:** [February 1, 2008, 6:00pm UTC](https://www.ruby-forum.com/t/rubygems-and-env-vars/127780/4 "2008-02-01T18:00:22Z")

</div>

On Feb 1, 2008, at 10:54 AM, Une Bévue wrote:

> ~/work/Ruby19/rb-appscript/Finder%\> ruby19 desktop.rb  
> /opt/local/lib/ruby/site\_ruby/1.8/\_aem/aemreference.rb:15:in `new’:  
> Not  
> a four-char-code string. (ArgumentError)

Oh, in that case, your Ruby install is broken and I’m out of good  
ideas. 🙂

James Edward G. II
