views:

96

answers:

2

Hi, using OS X 10.5.6 I installed fxruby using

$sudo port install rb-fxruby

As suggested in the book.

It works, my hello world program worked correctly.

Now, though, other code that I have written is broken, whenever I try to use any code that relies on a gem, it does not work. When I do $ruby -e "require 'rubygems'" in my code, it gives

"LoadError: no such file to load — rubygems" 

When I set my RUBYOPT="rubygems" in my .bash_profile

$ruby -e "puts 'hello world'"
ruby: no such file to load -- ubygems (LoadError)

(it says 'ubygems' without the 'r' on the front, not sure why)

http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2008-08/msg00351.html suggests I check my gem location against my ruby location, I get:

$cat `which gem` | head -n 1
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

$ls -l `which ruby`
-rwxr-xr-x  2 root  admin  12680 Feb  7 03:40 /opt/local/bin/ruby

I assume this means that the gems are confused, but not sure how to remedy it. Any ideas? It sucks not having gems.

---UPDATE---

Forgot to list versions:

$which gem
/usr/bin/gem

$gem --version
1.3.5

$ruby --version
ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9]
+1  A: 

It looks like you are trying to use the Apple-supplied gem that works with the Apple-supplied ruby. Did you install the MacPorts version?

sudo port install rb-rubygems
/opt/local/bin/gem
Ned Deily
The rubygems I have was installed when I bought the computer. I do not have a file gem at /opt/local/bin. Should I try installing rubygems via macports? I kind of feel like it changed a path variable or something, and if I could figure out which one / where, then I could fix it, but I have no idea where to look.
Joshua Cheek
I'm not a ruby expert but I suspect that, by default, installed gems are associated with a specific ruby instance so when you install the MacPorts ruby you need its rubygems package as well and then you'll likely have to reinstall the gems you need using it. In general, MacPorts packages try hard to keep everything separate from Apple-supplied versions included in OS X.
Ned Deily
+1  A: 

If you installed rb-fxruby via macport it will install the macport ruby as well.

$ port info rb-fxruby
...
Library Dependencies: ruby, fox, fxscintilla
...

But as you can see rb-rubygems (the macport version of rubygems) is not listed as a dependency, so you will have to install it manually.

$ sudo port install rb-rubygems

should do it for you.

thestoneage