Forum: wxRuby OS X Snow Leopard + wxRuby 2.0.1 gem - WORKING

Posted by Alex Fenton (Guest)
on 2010-07-07 11:40
(Received via mailing list)
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) install it from the downloaded file

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

3) 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)
http://weblog.rubyonrails.org/2009/8/30/upgrading-...

alex
Posted by Zhimin Zhan (zzhan)
on 2010-07-08 00:00
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
Posted by Mario Steele (Guest)
on 2010-07-08 01:27
(Received via mailing list)
That would be correct, you would need a 32 bit copy of nokogiri, in 
order
for it to work properly.
Posted by Zhimin Zhan (zzhan)
on 2010-07-08 14:40
Alex & Mario,

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

Regards,
Zhimin
Posted by Chloro Form (tony44)
on 2010-09-13 14:13
Sweet. Runs perfectly on my 10.6.4 machine.

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

Thanks,
Tony
Posted by Ridge McGhee (rmcghee)
on 2010-12-22 07:28
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 http://pragmaticstudio.com/blog/2010/9/23/install-...)

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
Posted by Alex Fenton (Guest)
on 2010-12-22 13:40
(Received via mailing list)
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 http://pragmaticstudio.com/blog/2010/9/23/install-...)
>
> 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
Posted by tiger zen (puti313)
on 2012-11-28 08:13
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 Fenton 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) install it from the downloaded file
>
> sudo gem install wxruby-2.0.1-universal-darwin-9.gem
>
> 3) 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)
> http://weblog.rubyonrails.org/2009/8/30/upgrading-...
>
> alex
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.