What is different between Ruby in standard OS X distribution, RVM and MacPorts?
Question
I have asked a question on SuperUser about updating Ruby version in Google SketchUp. It seems that there is something different between Ruby shipped with the standard OS X distribution, and Ruby installed by RVM or MacPorts. I get the following error message when I try to use RVM's or MacPorts' Ruby 1.9.1
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Dyld Error Message:
Library not loaded: @executable_path/../Frameworks/Ruby.framework/Versions/A/Ruby
Referenced from: /Applications/Google SketchUp 7/SketchUp.app/Contents/MacOS/SketchUp
Reason: no suitable image found. Did find:
/Applications/Google SketchUp 7/SketchUp.app/Contents/MacOS/../Frameworks/Ruby.framework/Versions/A/Ruby: mach-o, but wrong architecture
/Applications/Google SketchUp 7/SketchUp.app/Contents/MacOS/../Frameworks/Ruby.framework/Versions/A/Ruby: mach-o, but wrong architecture
/usr/lib/Ruby: not a file
Model: MacBookPro7,1, BootROM MBP71.0039.B05, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.62f5
But it works with Ruby 1.8.7 from /System/Library/Frameworks/Ruby.framework/
UPDATE1
As it was explained by Alex I need to compile Ruby with i386
architecture. One can do it for MacPorts and RVM, but none of the methods worked for me due to various errors.
So I decided to compile Ruby 1.9.2-rc2
from sources
$ ARCHFLAGS="-arch i386" CFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure --with-arch=i386
$ make && sudo make install
and copy corresponding files to SketchUp
$ cd /Applications/Google\ SketchUp\ 7/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/A/
$ rm -r Headers Ruby
$ cp /usr/local/bin/ruby Ruby
$ mkdir Headers
$ cp /usr/local/include/ruby-1.9.1/i386-darwin10.4.0/ruby/config.h Headers/
$ cp /usr/local/include/ruby-1.9.1/ruby.h Headers/
$ cp -r /usr/local/include/ruby-1.9.1/ruby/* Headers/
$ ls Headers
backward/ defines.h dl.h intern.h missing.h re.h ruby.h util.h vm.h
config.h digest.h encoding.h io.h oniguruma.h regex.h st.h version.h
This time I have got the following message
Dyld Error Message:
Library not loaded: @executable_path/../Frameworks/Ruby.framework/Versions/A/Ruby
Referenced from: /Applications/Google SketchUp 7/SketchUp.app/Contents/MacOS/SketchUp
Reason: no suitable image found. Did find:
/Applications/Google SketchUp 7/SketchUp.app/Contents/MacOS/../Frameworks/Ruby.framework/Versions/A/Ruby: can't map
/Applications/Google SketchUp 7/SketchUp.app/Contents/MacOS/../Frameworks/Ruby.framework/Versions/A/Ruby: can't map
/usr/local/lib/Ruby: not a file
/usr/lib/Ruby: not a file
Solution
Looks like you have versions of the Ruby
library in the sketchup directories for two architectures (probably 32-bit intel, and PPC, I'd guess) and are trying to use a Ruby binary built of a third and different architecture (probably 64-bit intel, I'd guess). You can check with the arch
command at a Terminal.App shell prompt.
If this should indeed prove to be the problem, you could maybe try to build a 1.9 ruby from sources, targeting 32-bit intel CPUs...? (I don't know of any prepackaged ruby 1.9 for mac built for 32-bit intel CPUs -- of course, there might well be some I don't know about!-).
OTHER TIPS
Was this solved? To answer the general question in your title, which is why I clicked on this:
System Ruby (1.8.7, I think) comes preloaded and is not overwritten by MacPorts or RVM. MacPorts writes by default to a different directory and Terminal begins to resolve to that new installation, leaving system Ruby sitting unused. RVM creates its own virtual installations of Ruby and can switch between those and system Ruby using $ rvm use
.