1

I'm running the default Ruby installation (ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10]) on my Intel iMac. I updated RubyGems and installed the wxruby gem. I'm trying to run the following sample program:

#!/usr/bin/ruby
require "rubygems"
require "wx"


class MyApp < Wx::App
    def on_init
        @frame = Wx::Frame.new(nil, -1, "The Bare Minimum")
        @frame.show()
    end
end

app = MyApp.new()
app.main_loop()

And I get the following error:

==> wxruby-test.rb
/Library/Ruby/Gems/1.8/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle, 9): no suitable image found.  Did find: (LoadError)
    /Library/Ruby/Gems/1.8/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle: no matching architecture in universal wrapper - /Library/Ruby/Gems/1.8/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
    from /Library/Ruby/Gems/1.8/gems/wxruby-1.9.3-universal-darwin/lib/wx.rb:12
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `require'
    from wxruby-test.rb:3

If I comment out the require rubygems statement, I get the following error:

==> wxruby-test.rb
wxruby-test.rb:3:in `require': no such file to load -- wx (LoadError)
    from wxruby-test.rb:3

I'm new to Ruby on the Mac, and I'm sure this is some basic error probably related to paths, but most explanations about the environment variables are aimed at experienced users. If you need more output from other commands, please let me know. I'm running Ruby from the tcsh shell. I'm sure I'm doing something basic wrong, but I'm just stumped.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303

2 Answers2

0

If you're running Ruby 1.8.7 you should leave in the require statement:

require "rubygems"

Ruby 1.8 didn't know about gems by default, so we had to tell Ruby to require the gems loader. Ruby 1.9+ bundles it so we no longer have to do the require.

This has nothing to do with the Mac (or Windows or Linux) OS, it's about Ruby's default load paths.

And, as a safety tip, don't mess with Ruby installed by Apple. They installed it for their own use, and it's used for some podcast-creation tools. And, at some future point they might want to add something to the system that takes advantage of an expected configuration of Ruby (or Python or Perl). Changing (or worse, deleting it) can mess you up. So, I recommend you leave it alone and use either rbenv or RVM to install Ruby in a sandbox, where you can poke, prod and mess with it safely.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • OP is using 'require "rubygems"' and it's finding the gem, but failing to load a requirement. Read the question more carefully. – Mark Reed Nov 04 '12 at 20:26
  • The OP has several things going on and said, "If I comment out the `require 'rubygems'`...". THAT is what I am addressing, along with screwing with the system's Ruby. Why WX isn't loading is a separate issue among three in the question. – the Tin Man Nov 04 '12 at 20:42
0

What version of OS X? If it's one of the Lions, then you're out of luck. The wxwidgets library (and things based on it, like wxruby) is still only 32-bit and based on Carbon. The Lions are 64-bit-only and Carbon is deprecated.

Mark Reed
  • 91,912
  • 16
  • 138
  • 175