Cannot load wxruby in IRB

Hi,

I am new to ruby and trying to make a simple desktop app using wxruby.

When I do: require ‘wx’ I get this error:

irb(main):001:0> require ‘wx’
LoadError:
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle,
9): no suitable image found. Did find:
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle:
no matching architecture in universal wrapper -
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle
from
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wx.rb:12:in
require' from /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wx.rb:12:in<top (required)>’
from (irb):1:in require' from (irb):1 from /usr/local/bin/irb:12:in

Any suggestions?

Thanks

Hi

On 07/07/2010 07:39, Utkarsh Sengar wrote:

I am new to ruby and trying to make a simple desktop app using wxruby.

Welcome.

When I do: require ‘wx’ I get this error:

Unfortunately, you can’t use wx interactively in irb. A gui app depends
on entering an ‘event loop’ where it waits for the user to do something.
This will just hang in irb.

irb(main):001:0> require ‘wx’
LoadError:
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle,

What OS X version are you on? 1.9.3 is a very old version, the current
release is 2.0.1. You may be on Snow Leopard (10.6) in which case you’ll
need to look in the recent m.l. archives for a user-contributed gem -
unfortunately I haven’t got the trunk stable to build on this version
yet.

alex

Thanks for the info Alex.

I am running Mac OS X 10.6. I dug up the archives and got the 2.0.1 for
10.6 here: Static gem of wxruby 2.0.1 for OS X Snow Leopard - wxRuby - Ruby-Forum

I installed the gem:

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

Regarding “require ‘wx’” in irb, I was just testing if I will be able to
use wx in my ruby code or not. I guess, ONLY “require ‘wx’” should give
me a ->true right?

So, after installing 2.0.1 and doing a “require ‘wx’”, i got this error:

irb(main):001:0> require ‘wx’
LoadError:
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle,
9): Symbol not found: _ZN10wxCheckBox13MacControlHitEPvS0
Referenced from:
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle
Expected in: flat namespace

/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle
from
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wx.rb:12:in
require' from /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wx.rb:12:in <top (required)>’
from (irb):1:in require' from (irb):1 from /usr/local/bin/irb:12:in

I get the same error if i do a “require ‘wx’” in a .rb file and try to
run it.

Thanks :slight_smile:

Alex F. wrote:

Hi

On 07/07/2010 07:39, Utkarsh Sengar wrote:

I am new to ruby and trying to make a simple desktop app using wxruby.

Welcome.

When I do: require ‘wx’ I get this error:

Unfortunately, you can’t use wx interactively in irb. A gui app depends
on entering an ‘event loop’ where it waits for the user to do something.
This will just hang in irb.

irb(main):001:0> require ‘wx’
LoadError:
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle,

What OS X version are you on? 1.9.3 is a very old version, the current
release is 2.0.1. You may be on Snow Leopard (10.6) in which case you’ll
need to look in the recent m.l. archives for a user-contributed gem -
unfortunately I haven’t got the trunk stable to build on this version
yet.

alex

Hi Alex,

I checked my ruby version and it was:

ruby 1.9.1p0 (2009-01-20 revision 21700) [i386-darwin10.4.0]

I followed your directions here: OS X Snow Leopard + wxRuby 2.0.1 gem - WORKING - wxRuby - Ruby-Forum
but it didn’t work.

Any suggestions?

Thanks

Alex F. wrote:

On 07/07/2010 10:19, Mr zengr wrote:

use wx in my ruby code or not. I guess, ONLY “require ‘wx’” should give
me a ->true right?

Yes. Although ultimately it would be nice to be able to test a GUI
design interactively.

So, after installing 2.0.1 and doing a “require ‘wx’”, i got this error:

irb(main):001:0> require ‘wx’
LoadError:
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle,
9): Symbol not found: _ZN10wxCheckBox13MacControlHitEPvS0

Sorry, I can’t provide support for this gem - I didn’t build it.

You may be a bit stuck for getting wxRuby working with the system ruby
provided in 10.6. Apple has made things difficult by moving to 64-bit
architecture, since Carbon (that provides much of wxWidgets 2.8 GUI) is
32-bit only.

I’m using 10.6 and for wxRuby applications I’m using my own 32-bit build
of Ruby 1.9.1. This works just fine with the gems that are downloadable
from Rubyforge. Alternatively I can use the 2.0.1 build by using the
arch command - see following post.

alex

On 07/07/2010 10:19, Mr zengr wrote:

use wx in my ruby code or not. I guess, ONLY “require ‘wx’” should give
me a ->true right?

Yes. Although ultimately it would be nice to be able to test a GUI
design interactively.

So, after installing 2.0.1 and doing a “require ‘wx’”, i got this error:

irb(main):001:0> require ‘wx’
LoadError:
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle,
9): Symbol not found: _ZN10wxCheckBox13MacControlHitEPvS0

Sorry, I can’t provide support for this gem - I didn’t build it.

You may be a bit stuck for getting wxRuby working with the system ruby
provided in 10.6. Apple has made things difficult by moving to 64-bit
architecture, since Carbon (that provides much of wxWidgets 2.8 GUI) is
32-bit only.

I’m using 10.6 and for wxRuby applications I’m using my own 32-bit build
of Ruby 1.9.1. This works just fine with the gems that are downloadable
from Rubyforge. Alternatively I can use the 2.0.1 build by using the
arch command - see following post.

alex

On 08/07/2010 06:34, Mr zengr wrote:

ruby 1.9.1p0 (2009-01-20 revision 21700) [i386-darwin10.4.0]

I followed your directions here: OS X Snow Leopard + wxRuby 2.0.1 gem - WORKING - wxRuby - Ruby-Forum
but it didn’t work.

What happened?

Alex F. wrote:

On 08/07/2010 06:34, Mr zengr wrote:

ruby 1.9.1p0 (2009-01-20 revision 21700) [i386-darwin10.4.0]

I followed your directions here: OS X Snow Leopard + wxRuby 2.0.1 gem - WORKING - wxRuby - Ruby-Forum
but it didn’t work.

What happened?

I am sorry for not detailing the error, when I ran this:

arch -i386 ruby -rubygems ruby-file.rb

I got this error “arch: posix_spawnp: ruby: Bad CPU type in executable”

So, did “uname -m” in my terminal and got i386. So, it seems I am in the
32bit kernel mode. That’s why “ruby --version” also returned
i386-darwin10.4.0.

So, to summarize:

  1. I am running 32bit ruby 1.9.1 on Mac OS X 10.6 Snow Leopard
  2. I manually installed wxruby (2.0.1 universal-darwin-9)
  3. When I do “require ‘wx’” I get this error:

/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wx.rb:12:in
require': dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wxruby2.bundle, 9): no suitable image found. Did find: (LoadError) /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wxruby2.bundle: no matching architecture in universal wrapper - /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wxruby2.bundle from /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wx.rb:12:in <top (required)>’
from ruby-file.rb:1:in require' from ruby-file.rb:1:in

Thanks a lot for your help!

On 08/07/2010 09:23, Mr zengr wrote:

  1. I am running 32bit ruby 1.9.1 on Mac OS X 10.6 Snow Leopard

In that case, there should be no problem - just use the standard gem for
Ruby 1.9:

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

You shouldn’t need to mess around with ‘arch’ b/c both the executable
and gem are simple 32-bit (actually, the gem is dual intel/ppc)

  1. I manually installed wxruby (2.0.1 universal-darwin-9)

Sounds like you may have installed the gem for Ruby 1.8 by mistake?

On 09/07/2010 03:31, Mr zengr wrote:

/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wxruby2.bundle:
no matching architecture in universal wrapper -

Hmm - did you compile your Ruby 1.9 under OS X 10.6? This may be the
mismatch. My ruby 1.9 (which works with the gem) is a version I compiled
before upgrading. There may be some compile flags for Ruby 1.9 to force
arch and 10.5 compatibility. But I don’t know what they are.

Can you use Ruby 1.8? If so, the 10.6 system ruby in /usr/bin/ruby
should work with the 1.8 gem, using arch.

I am sorry for my never ending problems, I think i will shift to my
Ubuntu VM.

No problem - I blame Apple! Each platform has its own annoyances,
though.

alex

Alex F. wrote:

On 08/07/2010 09:23, Mr zengr wrote:

  1. I am running 32bit ruby 1.9.1 on Mac OS X 10.6 Snow Leopard

In that case, there should be no problem - just use the standard gem for
Ruby 1.9:

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

I installed this gem and get the same error when I run this
(http://wxruby.rubyforge.org/wiki/wiki.pl?Getting_Started) sample code
by:

$ ruby sample.rb

/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wx.rb:12:in
require': dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wxruby2.bundle, 9): no suitable image found. Did find: (LoadError) /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wxruby2.bundle: no matching architecture in universal wrapper - /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wxruby2.bundle from /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wx.rb:12:in <top (required)>’
from ruby-file.rb:1:in require' from ruby-file.rb:1:in

You shouldn’t need to mess around with ‘arch’ b/c both the executable
and gem are simple 32-bit (actually, the gem is dual intel/ppc)

  1. I manually installed wxruby (2.0.1 universal-darwin-9)

Sounds like you may have installed the gem for Ruby 1.8 by mistake?

I am sorry for my never ending problems, I think i will shift to my
Ubuntu VM.

Thanks