OS X Snow Leopard + wxRuby 2.0.1 gem - WORKING

Hi

It is possible to use the standard wxRuby 2.0.1 gem with the standard
system ruby in /usr/bin/ruby in OS X 10.6

  1. download the gem

http://rubyforge.org/frs/download.php/63386/wxruby-2.0.1-universal-darwin-9.gem

  1. install it from the downloaded file

sudo gem install wxruby-2.0.1-universal-darwin-9.gem

  1. run ruby like this, forcing 32-bit mode

arch -i386 ruby -rubygems <scriptfile.rb>

Have tested with a couple of samples and this works fine. Appreciate any
feedback. Of course, we are still aiming to get full compatibility, but
for various reasons this is quite difficult.

Thanks to some advice on this page (comment #4)

alex

Thanks Alex.

Tested it with my app on Snow Leopard, it started OK until “require
‘nokogiri’”

Here is output:

/Library/Ruby/Gems/1.8/gems/nokogiri-1.4.2/lib/nokogiri/nokogiri.bundle:
dlopen(/Library/Ruby/Gems/1.8/gems/nokogiri-1.4.2/lib/nokogiri/nokogiri.bundle,
9): no suitable image found. Did find: (LoadError)
/Library/Ruby/Gems/1.8/gems/nokogiri-1.4.2/lib/nokogiri/nokogiri.bundle:
mach-o, but wrong architecture -
/Library/Ruby/Gems/1.8/gems/nokogiri-1.4.2/lib/nokogiri/nokogiri.bundle

I guess that’s because Nokogiri is built with 64-bit.

Zhimin

That would be correct, you would need a 32 bit copy of nokogiri, in
order
for it to work properly.

Sweet. Runs perfectly on my 10.6.4 machine.

Did anyone manage to launch the 32bit ruby environment from Netbeans?

Thanks,
Tony

Alex & Mario,

Yes, My app now works on Snow Leopard (after using 32-bit nokogiri),
Thanks!

Regards,
Zhimin

Some good news…

Alex, your method didn’t work for me immediately but I found a method
that works for me and may help others.

I have a MacBook Pro (64-bit) running OS X 10.6.
Like others, I wanted to run Ruby 1.9.2 (latest) and wxRuby 2.0.1
(latest).

I use RVM to install Ruby 1.9.2 (and manage my ruby versions).
(See Installing Ruby and Rails on Mac OS X)

By default, RVM builds the Ruby 64-bit version (only).
I finally found a post that indicates how to build both 32-bit and
64-bit versions of Ruby.

Briefly, here’s how users can get both built:
rvm install ruby-1.9.2-head -C --with-arch=x86_64,i386

Here’s how to check what you have:
file which ruby | perl -pe ‘s|^.*/||’

(Which will produce output like this:)
ruby: Mach-O universal binary with 2 architectures
ruby (for architecture x86_64): Mach-O 64-bit executable x86_64
ruby (for architecture i386): Mach-O executable i386

Visit:
http://rubyforge.org/frs/?group_id=35

And, download this gem:
wxruby-ruby19-2.0.1-x86-darwin-9.gem

Now, install the gem (no sudo required):
(Note, you may want to cd to your Downloads folder.)
gem install wxruby-ruby19-2.0.1-x86-darwin-9
Successfully installed wxruby-ruby19-2.0.1-x86-darwin-9

Create a wxruby test script (wxtest.rb):

#!/usr/bin/env arch -i386 ruby

require ‘wx’
include Wx

App.run do
frame = Frame.new(nil, :title => ‘So far, so good…’)
frame.show
end

And run it:

ruby wxtest.rb

Ok, so this particular working set produced a window.
So, we (or I anyway) have a way to proceed.

Alex - I hope this somehow helps you find out what the problem
(32-bit vs 64-bit) might be. Any thoughts?

Cheers,
Ridge

bad news
the output is:
/Users/rubyzen/rubymineprojects/wxruby/first_window.rb
arch: posix_spawnp: ruby: Bad CPU type in executable

kouheimatoMacBook-Air:wxruby rubyzen$ arch -i386 ruby -rubygems
/Users/rubyzen/rubymineprojects/wxruby/first_window.rb
arch: posix_spawnp: ruby: Bad CPU type in executable

xiong-kouheimatoMacBook-Air:wxruby rubyzen$ arch
i386

xiong-kouheimatoMacBook-Air:wxruby rubyzen$ ruby -v
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin10.8.0]
xiong-kouheimatoMacBook-Air:wxruby rubyzen$ which ruby
/Users/rubyzen/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
xiong-kouheimatoMacBook-Air:wxruby rubyzen$ gem q -d -n wxruby
/Users/rubyzen/.rvm/rubies/ruby-1.9.2-p320/bin/gem:4: warning: Insecure
world writable dir /usr in PATH, mode 040777

*** LOCAL GEMS ***

wxruby (2.0.1)
Platform: universal-darwin-9
Author: wxRuby development team
Rubyforge: http://rubyforge.org/projects/wxruby
Homepage: http://wxruby.org/
Installed at: /Users/rubyzen/.rvm/gems/ruby-1.9.2-p320

Ruby interface to the wxWidgets GUI library

xiong-kouheimatoMacBook-Air:wxruby rubyzen$ file
/Users/rubyzen/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
/Users/rubyzen/.rvm/rubies/ruby-1.9.2-p320/bin/ruby: Mach-O 64-bit
executable x86_64

xiong-kouheimatoMacBook-Air:lib rubyzen$ file wxruby2.bundle
wxruby2.bundle: Mach-O universal binary with 2 architectures
wxruby2.bundle (for architecture ppc): Mach-O bundle ppc
wxruby2.bundle (for architecture i386): Mach-O bundle i386

Alex F. wrote in post #923756:

Hi

It is possible to use the standard wxRuby 2.0.1 gem with the standard
system ruby in /usr/bin/ruby in OS X 10.6

  1. download the gem

http://rubyforge.org/frs/download.php/63386/wxruby-2.0.1-universal-darwin-9.gem

  1. install it from the downloaded file

sudo gem install wxruby-2.0.1-universal-darwin-9.gem

  1. run ruby like this, forcing 32-bit mode

arch -i386 ruby -rubygems <scriptfile.rb>

Have tested with a couple of samples and this works fine. Appreciate any
feedback. Of course, we are still aiming to get full compatibility, but
for various reasons this is quite difficult.

Thanks to some advice on this page (comment #4)
Ruby on Rails — Upgrading to Snow Leopard

alex

Hi Ridge

On 22/12/2010 06:28, Ridge McGhee wrote:

I have a MacBook Pro (64-bit) running OS X 10.6.
Like others, I wanted to run Ruby 1.9.2 (latest) and wxRuby 2.0.1
(latest).
That sounds similar to my setup.

I use RVM to install Ruby 1.9.2 (and manage my ruby versions).
(See Installing Ruby and Rails on Mac OS X)

By default, RVM builds the Ruby 64-bit version (only).
I finally found a post that indicates how to build both 32-bit and
64-bit versions of Ruby.

I hadn’t come across RVM - this looks great.

Ok, so this particular working set produced a window.
So, we (or I anyway) have a way to proceed.

Alex - I hope this somehow helps you find out what the problem
(32-bit vs 64-bit) might be. Any thoughts?

I’m just headed off for xmas so won’t have a go at this til new year -
but it sounds very promising as a way to restart development on the
stable branch with 10.6. What I’ll need to test is that I can use this
ruby to compile against wxWidgets 2.8 - which is what has been the
headache so far.

best wishes
alex

Alex F. wrote in post #923756:

Hi

It is possible to use the standard wxRuby 2.0.1 gem with the standard
system ruby in /usr/bin/ruby in OS X 10.6

  1. download the gem

http://rubyforge.org/frs/download.php/63386/wxruby-2.0.1-universal-darwin-9.gem

  1. install it from the downloaded file

sudo gem install wxruby-2.0.1-universal-darwin-9.gem

  1. run ruby like this, forcing 32-bit mode

arch -i386 ruby -rubygems <scriptfile.rb>

Have tested with a couple of samples and this works fine. Appreciate any
feedback. Of course, we are still aiming to get full compatibility, but
for various reasons this is quite difficult.

Thanks to some advice on this page (comment #4)
Ruby on Rails — Upgrading to Snow Leopard

alex

Hello,

I tried this and for me, that’s not works.

I install ruby-1.9.3-p448 with rvm
and then, install wxruby-2.0.1-darwin from gem source
and then, call ruby on i386 (wich is my arch) for my hello.rb file (who
use wx code)

but this said my that it is the bad cpu…

do you have an idea ?

install ruby 1.9

rvm install 1.9.3 -C --with-arch=i386

switch to ruby 1.9.3 (rvm use…)

install this version:
http://rubyforge.org/frs/download.php/63385/wxruby-ruby19-2.0.1-x86-darwin-9.gem

and run your script:

ruby <yourscript.rb>

it works for me.

Cheers,

fabio.

Fabio P. wrote in post #1117980:

install ruby 1.9

rvm install 1.9.3 -C --with-arch=i386

switch to ruby 1.9.3 (rvm use…)

install this version:
http://rubyforge.org/frs/download.php/63385/wxruby-ruby19-2.0.1-x86-darwin-9.gem

and run your script:

ruby <yourscript.rb>

it works for me.

Cheers,

fabio.

Thanks Fabio, now the server seems to works great and i can have my
ruby-1.9.3-p448 universal (because, the ruby package from githurb is
not… i give him, and try this before for change the arch compilation
for install , but it is not the same package… github on the site talk
about no have implementation down to osx-10.7 for his GUI software and
said that it is because fo some tools that is not in osx-10.6.8 … so
maybe that is why also they don’t have the complete ruby package
universal… i’m really sorry with this segregation from github.com
…) and that’s works great for me also.

But… do you have the same warning about libyaml ?
I try to install this from rvm (rvm install yaml… rvm install libyaml,
etc…) without any success. (it is really difficult to have something
good on osx-10.6.8… but i don’t want to change for osx-10.7… and i
don’t like the new politic and practice of apple for lot of thinks…

if you find solution for libyaml warning, i give it so…
if i find before, i take it so.

thanks Fabio

ok, hello again, i find it:

0 with the jewerlybox i update rvm to the nex last version (can do by
terminal)
1 remove all ruby-1.9.3 sources from Users/“HOME”/.rvm/src and
/Users/“HOME”/.rvm/archive
2 rvm get head
3 rvm reload
4 rvm install 1.9.3 -C --with-arch=i386 (again)
5 rvm use 1.9.3

that’s works for me, no more libyaml warnings (so, irb can be use to).

thanks to everybody for read and help, and have a good day.

ok, i find this:

they talk about doing an i386 install of libyaml with this code:

CONFIGURE_OPTS=“–with-arch=i386” CFLAGS=“-arch i386” LDFLAGS=“-arch
i386” rvm pkg install libyaml

and so, reinstall the ruby (same code, but reinstall in place of install
not works for me: error -j2) with exactly same procedure from rvm
install -C again…

I just do it, and so…

not works, error -j2.

i will see again tomorrow.

also, i find something maybe i,nterest you about osx-10.6.X
you can change your arch from boot (push buttons “6” and “4” in the same
time) for x86_64.
And then, try it and if of, you can also change definitively for this
arch (go for a look on apple site about “change arch from 32 to 64
bits”), it is really simple (don’t follow other link where all is more
complicate for nothing more).

after that, install will be more easy for all dependencies.

(so… if you have some virtual machines, maybe take care about
necessity to reinstall them again…)