RubyGems and ENV vars?

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:inpack_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:inmodule: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:inrequire’
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:inrequire’
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:inmodule: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:inrequire’
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 ?

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

Hope that helps.

James Edward G. II

James G. [email protected] 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

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 ???

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. :slight_smile:

James Edward G. II