views:

74

answers:

1

Currently Google SketchUp for Mac has Ruby version 1.8.5 which I find a bit outdated. I can update Ruby to 1.8.7 (OSX's version) by the following commands

$ cd /Applications/Google\ SketchUp\ 7/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/Current
$ ls
Headers/       Resources/     Ruby
$ ls Headers/
config.h  defines.h intern.h  missing.h ruby.h

$ rm -r Headers
$ ln -s  /System/Library/Frameworks/Ruby.framework/Headers
$ ln -fs /System/Library/Frameworks/Ruby.framework/Ruby

SketchUp starts without a problem and Ruby console shows version 1.8.7.

1.9.2

Now I try to go further and update to 1.9.2-rc2. Google SketchUp requires i386 binary, which can be produced by the following commands

$ cd ~/ruby-1.9.2-rc2/
$ ARCHFLAGS="-arch i386"  CFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure  --with-arch=i386
$ make && sudo make install

Then I copy the necessary files to SketchUp:

$ cd /Applications/Google\ SketchUp\ 7/SketchUp.app/Contents/Frameworks/Ruby.framework/
$ rm 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

and when I try to start SketchUp I get the following error report

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: 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

Model: MacBookPro7,1, BootROM MBP71.0039.B05, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.62f5

Could you tell me why?

UPDATE1

Dan Rathbun made some tests and found the following

On Win32 when I tried to get Sketchup to load any 1.9.x I got an "Entry point not found" for the ruby C function "rb_set_kcode" which is no longer in 1.9.x (it was renamed, and the Ruby people did not alias the old name to the new name.)

Basically Sketchup calls rb_set_kcode to set the character encoding to UTF8 just after loading the Ruby interpreter. It works fine for any Ruby in the 1.8.x branch, but in 1.9.x the Ruby project totally reengineered the character encoding, and gave all the C functions new identifiers, and added alot more functions.

The solution for 1.9.x and Sketchup seems to be that Sketchup needs to be "Ruby Version Agile", which means a coding change by the Google Guys in Boulder.

+1  A: 

The C level API has changed in 1.9.1. Notice that the paths to gems indicate the API compatibility: .../1.8/... for the 1.8 line and .../1.9.1/... for the 1.9.2 line.

This makes it very difficult to upgrade without recompiling.

You can require "backports"; this will get you the most of the new methods of 1.9.x, but not the new syntax or the string encoding.

Marc-André Lafortune
If SketchUp needs just some minor changes in Ruby sources to run `1.9.x`, then recompiling is fine for me. However, I will probably not find it myself due to the lack of experience in C-programming. As a workaround, I am going to write a DSL in Ruby `1.8.7` to work with my `1.9.x` classes via intermediate ruby-files, being loaded in SketchUp. I really hope that it will finally be possible to run SketchUp with Ruby `1.9`, so that this unnecessary step will be skipped.
Andrey
Is Sketchup open source?
Marc-André Lafortune