[Mac OS X] rubygems and wxRuby

U

Une Bévue

i wanted to test wxRuby with the simplest script :
------------------------------------------------------------------------
#! /usr/bin/env ruby

# If you installed the wxruby gem, uncomment the following two lines:
require 'rubygems'
#gem 'wxruby-1.9.3-universal-darwin' #'wxruby2-preview'
# or the name of the gem you installed
#gem 'wxruby-1.9.3' #'wxruby2-preview'
gem 'wxruby'
require "wxruby" # wxruby 0.6.0
# OR
require "wx" # wxruby2
include Wx


class MinimalApp < App
def on_init
Frame.new(nil, -1, "The Bare Minimum").show()
end
end
------------------------------------------------------------------------

I've installed "wxruby-1.9.3-universal-darwin"

for the "gem" line if i use :
gem 'wxruby-1.9.3-universal-darwin' or
gem 'wxruby-1.9.3' i get an error :
/opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:499:in
`report_activate_error': Could not find RubyGem wxruby-1.9.3 (>= 0)
(Gem::LoadError)
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:131:in
`activate'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:49:in `gem'
from ./essai.rb:6


and, if i comment this line, i get an error with the following (require
"wxruby") :
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require': no such file to load -- wxruby (LoadError)
from
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
from ./essai.rb:8

obviously i've verified wxruby is installed :
$ gem list --local w

*** LOCAL GEMS ***

wx_sugar (0.1.20)
wxruby (1.9.3)

the installation of wxruby and wx_sugar have been done thru gem.
i didn't install anything (no dependencies)


MinimalApp.new.main_loop
 
A

Alex Fenton

Une said:
i wanted to test wxRuby with the simplest script :

As the wiki states, it's better to start with the samples bundled with
wxruby. Many of the examples on the wiki are dated.

On OS X, you can find the samples that installed with the gem at:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/user-gems/1.8/gems/wxruby-1.9.5-universal-darwin-9/samples/


basically you want just

require "rubygems"
require "wx"

at the start of your script.
I've installed "wxruby-1.9.3-universal-darwin"

the latest gem version is 1.9.6; I recommend you install that.

There are dedicated mailing lists for wxruby questions:
http://wxruby.rubyforge.org/wiki/wiki.pl?MailingLists

alex
 
U

Une Bévue

Alex Fenton said:
the latest gem version is 1.9.6; I recommend you install that.

Thanks for all.

i've installed wxruby by gem:
$ sudo gem install wxruby
then i wonder why i didn't get the latest version...
i'll uninstall and re-install after download.

also at the time being i get :
ruby
/opt/local/lib/ruby/gems/1.8/gems/wxruby-1.9.3-universal-darwin/samples/
minimal/minimal.rb
dyld: NSLinkModule() error
dyld: Library not loaded: /usr/lib/libiconv.2.dylib
Referenced from:
/opt/local/lib/ruby/gems/1.8/gems/wxruby-1.9.3-universal-darwin/lib/wxru
by2.bundle
Reason: Incompatible library version: wxruby2.bundle requires version
7.0.0 or later, but libiconv.2.dylib provides version 5.0.0
zsh: trace trap ruby

this is because (?) my ruby install has been done thru MacPorts:
$ which ruby
/opt/local/bin/ruby

$ ruby --version
ruby 1.8.6 (2007-09-24 patchlevel 111) [powerpc-darwin8.11.0]

and the dylib is under /opt :
$ locate libiconv.2.dylib
[...]
/opt/local/lib/libiconv.2.dylib
[...]

for those reasons i think it's best for me to compile wxruby ?
 
U

Une Bévue

Une Bévue said:
for those reasons i think it's best for me to compile wxruby ?

NO because the README recommends using gem, however :

~/work/Ruby/wxruby%> sudo gem install wxruby --version '>= 1.9.6'
ERROR: could not find wxruby locally or in a repository

may be the server is down, because i did it yesterday that way :
$ sudo gem install wxruby
Password:
Updating metadata for 12 gems from http://gems.rubyforge.org/
.............
complete
Successfully installed wxruby-1.9.3-universal-darwin
1 gem installed
 
A

Alex Fenton

Une said:
i've installed wxruby by gem:
$ sudo gem install wxruby
then i wonder why i didn't get the latest version...
i'll uninstall and re-install after download.

What version of OS X are you using?
also at the time being i get :
ruby
/opt/local/lib/ruby/gems/1.8/gems/wxruby-1.9.3-universal-darwin/samples/
minimal/minimal.rb
dyld: NSLinkModule() error
dyld: Library not loaded: /usr/lib/libiconv.2.dylib
Referenced from:
/opt/local/lib/ruby/gems/1.8/gems/wxruby-1.9.3-universal-darwin/lib/wxru
by2.bundle
Reason: Incompatible library version: wxruby2.bundle requires version
7.0.0 or later, but libiconv.2.dylib provides version 5.0.0
zsh: trace trap ruby

This may be part of the same problem.
for those reasons i think it's best for me to compile wxruby ?

Maybe, it's not hard if you have XCode installed. Unless you want to use
advanced features like OpenGL or Scintilla, you just compile wxWidgets
(./configure; make; make install) and then wxRuby (rake; then either
rake install or rake gem)

http://wxruby.rubyforge.org/wiki/wiki.pl?InstallingFromSource
http://wxruby.rubyforge.org/wiki/wiki.pl?HowToBuildWxWidgets

a
 
A

Alex Fenton

Une said:

If you're using 10.4, you'll need to use wxRuby version 1.9.4 or later.
1.9.7 is current. All recent versions are specifically built to be
compatible with 10.4 or 10.5.

Unfortunately about the same time rubygems became more pedantic about
compiler versions, which is why I guess you're not getting offered the
latest via remote gem install. I suggest you download it from here:

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

and install locally ("sudo gem install wxruby" in the folder where the
downloaded gem is saved).

if you have any further problems, please follow up on the wxruby-users
mailing list.

a
 
U

Une Bévue

Alex Fenton said:
if you have any further problems, please follow up on the wxruby-users
mailing list.

OK, i did subscribe to it.

right now i get a "welcome to wxRuby" from :

$> ruby
/opt/local/lib/ruby/gems/1.8/gems/wxruby-1.9.7-universal-darwin-9/sample
s/minimal/minimal.rb

thanks a lot !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,961
Messages
2,570,131
Members
46,689
Latest member
liammiller

Latest Threads

Top