gem installation oddity

P

Pito Salas

I have been totally puzzled by what I think is a misconfiguration of my
gem environment. I've read and looked and experimented and tried to
solve this. Maybe you can help.. Here's the top level symptom. I install
a gem, and then do a 'which' and gem says it can't find it:

sudo gem install wxruby
Successfully installed wxruby-2.0.0-universal-darwin-9
1 gem installed
Installing ri documentation for wxruby-2.0.0-universal-darwin-9...
Installing RDoc documentation for wxruby-2.0.0-universal-darwin-9...
/opt/local/lib/ruby/gems/1.8$ gem which wxruby
Can't find ruby library file or shared library wxruby
/opt/local/lib/ruby/gems/1.8$

This is not a peculiarity with this particular gem. There are others in
this odd state too. Here's some more context:

# GEM ENVIRONMENT
/opt/local/lib/ruby/gems/1.8$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-9
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.8
- /Users/pito/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/",
"http://gems.github.com"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
/opt/local/lib/ruby/gems/1.8$


# GEM SPECIFICATION FOR THE GEM IN QUESTION

/opt/local/lib/ruby/gems/1.8$ gem specification wxruby
--- !ruby/object:Gem::Specification
name: wxruby
version: !ruby/object:Gem::Version
version: 2.0.0
platform: universal-darwin-9
authors:
- wxRuby development team
autorequire:
bindir: bin
cert_chain: []

date: 2009-02-26 00:00:00 -05:00
default_executable:
dependencies: []
.... much more ....

# OTHER SHELL ENV

/opt/local/lib/ruby/gems/1.8$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

/opt/local/lib/ruby/gems/1.8$ echo $GEMPATH
/opt/local/lib/ruby/gems/1.8
/opt/local/lib/ruby/gems/1.8$
 
E

Eric Hodel

I have been totally puzzled by what I think is a misconfiguration of
my
gem environment. I've read and looked and experimented and tried to
solve this. Maybe you can help.. Here's the top level symptom. I
install
a gem, and then do a 'which' and gem says it can't find it:

sudo gem install wxruby
Successfully installed wxruby-2.0.0-universal-darwin-9
1 gem installed
Installing ri documentation for wxruby-2.0.0-universal-darwin-9...
Installing RDoc documentation for wxruby-2.0.0-universal-darwin-9...
/opt/local/lib/ruby/gems/1.8$ gem which wxruby
Can't find ruby library file or shared library wxruby
/opt/local/lib/ruby/gems/1.8$

This is not a peculiarity with this particular gem. There are others
in
this odd state too.

Is there even a wxruby in the gem?

gem contents -l wxruby

will tell you if you've got the gem installed

You can also check from the .gem file without installing:

$ gem fetch wxruby
Downloaded wxruby-2.0.0-universal-darwin-9
$ gem spec wxruby-2.0.0-universal-darwin-9.gem files | grep lib
- lib/wx
[...]
- lib/wx.rb
[...]

Nope.

Try:

require 'wx'

instead.

Hey look! It's even described right in the Getting Started tutorial:

http://wxruby.rubyforge.org/wiki/wiki.pl?Getting_Started

Which is linked off the homepage!

$ gem list -dr wxruby

*** REMOTE GEMS ***

wxruby (2.0.0, 1.9.7, 1.9.3, 1.9.2)
Platforms:
1.9.2: i686-darwin8.8.2, powerpc-darwin8.10.0
1.9.3: universal-darwin
1.9.7: i386-mswin32
2.0.0: universal-darwin-9, x86-linux, x86-mingw32, x86-
mswin32-60,
x86_64-linux
Author: wxRuby development team
Rubyforge: http://rubyforge.org/projects/wxruby
Homepage: http://wxruby.org/

Ruby interface to the wxWidgets GUI library
 
P

Pito Salas

Eric Hodel wrote:
I don't think I exactly followed this. But in the meanwhile I think I
have figured out what was tripping me up. The sample apps that come with
wxruby begin with a line that looks like this:

#!/usr/bin/env ruby
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
# Freely reusable code: see SAMPLES-LICENSE.TXT for details

Which, the way I was running it, led it to look at the ruby that comes
with OSX rather than the one I have designated as primary, which is
actually in /opt/local/... My gem install is going into the primary ruby
install so when the sample app runs, it's not finding it. So removing
that first line makes the thing work.

It still doesn't explain to me why this is happening, but it might be,
as the first response said, a bug in "gem which". It's a bit worrysome,
but for the moment it's not holding me up:

$ sudo gem install wxruby
Successfully installed wxruby-2.0.0-universal-darwin-9
1 gem installed
Installing ri documentation for wxruby-2.0.0-universal-darwin-9...
Installing RDoc documentation for wxruby-2.0.0-universal-darwin-9...
$ gem which wxruby
Can't find ruby library file or shared library wxruby
$

By the way, you asked:
Is there even a wxruby in the gem?

The code doesn't look for it; here's what it looks like:

#!/usr/bin/env ruby
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
begin
require 'rubygems'
rescue LoadError
end
require 'wx'
 
E

Eric Hodel

Eric Hodel wrote:
I don't think I exactly followed this. But in the meanwhile I think I
have figured out what was tripping me up. The sample apps that come
with
wxruby begin with a line that looks like this:

#!/usr/bin/env ruby
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
# Freely reusable code: see SAMPLES-LICENSE.TXT for details

Which, the way I was running it, led it to look at the ruby that comes
with OSX rather than the one I have designated as primary, which is
actually in /opt/local/...

Designate /opt/local/ruby as your primary ruby by setting your PATH,
then /usr/bin/env can work as designed.
My gem install is going into the primary ruby
install so when the sample app runs, it's not finding it. So removing
that first line makes the thing work.
It still doesn't explain to me why this is happening, but it might be,
as the first response said, a bug in "gem which". It's a bit
worrysome,
but for the moment it's not holding me up:

$ sudo gem install wxruby
Successfully installed wxruby-2.0.0-universal-darwin-9
1 gem installed
Installing ri documentation for wxruby-2.0.0-universal-darwin-9...
Installing RDoc documentation for wxruby-2.0.0-universal-darwin-9...
$ gem which wxruby
Can't find ruby library file or shared library wxruby
$

I told you that wxruby doesn't exist already.

You can use gem contents -l as in my previous mail to see which files
are in a gem to make a guess at what to use. Of course, you should go
read the documentation first if you can't immediately figure out how
to use the gem.
By the way, you asked:


The code doesn't look for it; here's what it looks like:

#!/usr/bin/env ruby
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
begin
require 'rubygems'
rescue LoadError
end
require 'wx'

Why are you still trying to require a file that doesn't exist (wxruby)
and that the documentation says doesn't exist (linked-to from my
previous mail)? The documentation tells you which file to require.
You even found a file that uses the wxruby gem and you're still
looking for the wrong file...

Not every gem name has a 1:1 mapping to the file you need to require.
When require name_of_gem doesn't work, you can use the various tools
from my previous email to find the file you need to require. Of
course the first spot you should check is the documentation for the
gem you're using.
 
P

Pito Salas

Eric said:
Designate /opt/local/ruby as your primary ruby by setting your PATH,
then /usr/bin/env can work as designed.

I think that's how I have it:

$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
~$ echo $GEMPATH
/opt/local/lib/ruby/gems/1.8/
~$
I told you that wxruby doesn't exist already.

You can use gem contents -l as in my previous mail to see which files
are in a gem to make a guess at what to use. Of course, you should go
read the documentation first if you can't immediately figure out how
to use the gem.


Why are you still trying to require a file that doesn't exist (wxruby)
and that the documentation says doesn't exist (linked-to from my
previous mail)? The documentation tells you which file to require.
You even found a file that uses the wxruby gem and you're still
looking for the wrong file...

Hm, I thought I was requiring wx.rb which in does exist. I agree that
wxruby does not exist. Am I missing it totally?

However, your reply has helped me also uncover another misunderstanding,
which may be what you were trying to say all along, that is that:

$gem which 'xxx'
looks for a file called xxx.rb in a gem, rather than a gem called xxx.
That's why my

$gem which wxruby

Keeps saying that it can't find it, but now I tried

$gem which wx

and that succeeds.
Not every gem name has a 1:1 mapping to the file you need to require.
When require name_of_gem doesn't work, you can use the various tools
from my previous email to find the file you need to require. Of
course the first spot you should check is the documentation for the
gem you're using.

Yeah, that's a key bit of the puzzle that I hadn't understood. Thanks!
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top