€œarch -i386 ruby” not loading into 32-bit mode in 10.6.3

<2.33GHz MBPC2D running OS X 10.6.3>

OSAX calls within the default 64-bit environment of OS X 10.6.3 (I have
not tried with earlier OS X versions) are failing when using what has
been recommended for forcing Ruby to run in 32-bit mode: “#! arch -i386
ruby”.

A test script, results, and software versions are appended below.

Thoughts?

Thanks!!

Richard F.

---- Script ----

#! arch -i386 ruby
require ‘rubygems’
require ‘appscript’; include Appscript
require ‘osax’; include OSAX
p scripting_additions
#=> [“Digital Hub Scripting”, “Numerics”, “Satimage”,
“SpeedDownloadLoader”, “StandardAdditions”, “XMLLib”]

so good so far and non-OSAX scripts run as expected, but

none of the following work:

osax.beep
osax.set_the_clipboard_to(“howdy”)
osax.say (“Hey, wake up.”, :using=>“Victoria”)

---- Results ----

RuntimeError: OSAX::ScriptingAddition can’t dynamically retrieve
scripting addition terminology within a 64-bit process.
from /Library/Ruby/Site/1.8/osax.rb:153:in initialize' from /Library/Ruby/Site/1.8/osax.rb:102:innew’
from /Library/Ruby/Site/1.8/osax.rb:102:in osax' from /Library/Ruby/Site/1.8/osax.rb:124:inosax’
from (irb):4

---- Software Versions ----

ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
RubyGems 1.3.6
StandardAdditions.osax version 2.1.2

To determine whether Ruby is running in 32bit or 64bit

[‘foo’].pack(‘p’).size #=> 8 on 64bit, 4 on 32bit, I got “8”

Richard F. wrote:

<2.33GHz MBPC2D running OS X 10.6.3>

OSAX calls within the default 64-bit environment of OS X 10.6.3 (I have
not tried with earlier OS X versions) are failing when using what has
been recommended for forcing Ruby to run in 32-bit mode: “#! arch -i386
ruby”.

Not clear how you ran it, but it sounds as if you’re still running in
64-bit mode.

To test the script, I changed the hashbang to ‘#!/usr/bin/env -i386
ruby’, saved it as ‘test.rb’, chmodded it to make it executable, and ran
it as ./test.rb, and it ran fine in 32-bit.

FWIW, I have a TODO on embedding Standard Additions terminology in the
OSAX module (I’ve already done this for py-appscript) so that it will
work on 64-bit as well. I still need to figure out Ruby 1.9’s text
encoding support before I do a new release though.

HTH

has

Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

Not clear how you ran it, but it sounds as if you’re still running in
64-bit mode.

I’ve been entering it manually into Terminal and also running it as an
AppleScript:

do shell script “ruby ‘/Applications/ Scripting/Ruby/Tests/test.rb’”

The results are the same in either case (as in initial post), only the
OSAX calls fail.

AFAICT, it is still in 64-bit mode. Early on I ran the following with
the noted result:

To determine whether Ruby is running in 32bit or 64bit

[‘foo’].pack(‘p’).size #=> 8 on 64bit, 4 on 32bit #=> I got “8”

To test the script, I changed the hashbang to ‘#!/usr/bin/env -i386
ruby’,

I tried that as an initial attempt and it didn’t work either.

chmodded it to make it executable,

I didn’t know that was necessary as other scripts ran fine, only the
OSAX calls failed. Please offer some wisdom as to how to set it as such,
if it is necessary!

and ran it as ./test.rb, and it ran fine in 32-bit.

I would love to be able to get the same results; at least I now know it
is possible in 10.6.3! Any other advice would be greatly appreciated! (I
love AppleScript. Really. I do. :wink: )

FWIW, I have a TODO on embedding Standard Additions terminology in the
OSAX module (I’ve already done this for py-appscript) so that it will
work on 64-bit as well. I still need to figure out Ruby 1.9’s text
encoding support before I do a new release though.

If you would like (yet another) beta-tester, just let me know!

:wink:

Thanks for your incredible efforts! Appscript is quite a blessing!

Richard F.

Richard F. wrote:

Not clear how you ran it, but it sounds as if you’re still running in
64-bit mode.

I’ve been entering it manually into Terminal and also running it as an
AppleScript:

do shell script “ruby ‘/Applications/ Scripting/Ruby/Tests/test.rb’”

The hashbang at the top of a script only applies when you execute the
script file directly. Since you’re invoking the ruby interpreter
yourself and passing the script path as an argument, it will be ignored.

Use:

do shell script “arch -i386 ruby ‘/Applications/
Scripting/Ruby/Tests/test.rb’”

FWIW, I have a TODO on embedding Standard Additions terminology in the
OSAX module (I’ve already done this for py-appscript) so that it will
work on 64-bit as well. I still need to figure out Ruby 1.9’s text
encoding support before I do a new release though.

If you would like (yet another) beta-tester, just let me know!

It’s in the subversion repository if you want to play with it.

HTH

has