Ruby Version for Sketchup 8.0 M1 on Mac ??
-
ok,
I'm having an issue,
I've got a button version that works fine on one of my SU.app install paths but not the other, even this basic excerpt won't work> if File.exists? "/Applications/Google\ SketchUp\ 8/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/A.orig" Thread.new { # Thread #2 runs this code system("cd /Applications/Google\ SketchUp\ 8/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions rm A mv A.orig A ") }; UI.messagebox("changing to RUBY_VERSION 1.8.5") else # RUBY_VERSION === "1.8.5" Thread.new{ # Thread #2 runs this code system("cd /Applications/Google\ SketchUp\ 8/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions mv A A.orig ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8 A ") }; UI.messagebox("changing to RUBY_VERSION 1.8.7") end #if 1 > File.exists? "/Applications/Google\ SketchUp\ 8/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/A.orig" true
# SU returns => RUBY_VERSION = 1.8.7 key = Units value = 0.0 > if File.exists? "/Applications/Sketchup.app/Contents/Frameworks/Ruby.framework/Versions/A.orig" Thread.new { # Thread #2 runs this code system("cd /Applications/Sketchup.app/Contents/Frameworks/Ruby.framework/Versions rm A mv A.orig A ") }; #UI.messagebox("changing to RUBY_VERSION 1.8.5") else # RUBY_VERSION === "1.8.5" Thread.new{ # Thread #2 runs this code system("cd /Applications/Sketchup.app/Contents/Frameworks/Ruby.framework/Versions mv A A.orig ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8 A ") }; #UI.messagebox("changing to RUBY_VERSION 1.8.7") end #if #<Thread;0x12cd6f4c sleep> > File.exists? "/Applications/Sketchup.app/Contents/Frameworks/Ruby.framework/Versions/A.orig" false
the only difference is the path
what does returning**1**
as opposed to**#<Thread:0x12cd6f4c sleep>**
help.... SOLVED, it is odd how posting helps
-
@driven said:
so, you need to double escape the system path, but single escape the ruby one.... aaahhhhhh
any testers, before I polish it?
Ah the joy of escapes! You need one \ to preserve the space in a path used by Ruby itself, but \ to pass along \ to preserve the space when the path will be sent to the system. Ack!!
I'll be tied up for a day or two with holiday obligations, but will be glad to try this out when I get some free time.
Steve
-
Cheers,
I'll have added the /usr/bin/irb/ $LOAD_PATH array to it by then...
an auto version of thisbegin a=["/Library/Ruby/Site/1.8", "/Library/Ruby/Site/1.8/universal-darwin12.0", "/Library/Ruby/Site", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby/1.8/universal-darwin12.0", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0", "."] a.each{|x| $; << x } rescue Exception print $! print $!.backtrace.join("\n") rescue StandardError print $! print $!.backtrace.join("\n") rescue RuntimeError print $! print $!.backtrace.join("\n") rescue print $! print $!.backtrace.join("\n") end $LOAD_PATH.uniq! # delete duplicate entries puts $LOAD_PATH.sort.join("\n")
and also
(
ruby -r rubygems -e "p Gem.path")
digging through all my past efforts
john -
@slbaumgartner said:
Ah the joy of escapes! You need one \ to preserve the space in a path used by Ruby itself, but \ to pass along \ to preserve the space when the path will be sent to the system. Ack!!
I found a new trick if you have
@apPath=("/Applications/Google\ SketchUp\ 8/SketchUp.app")
you can use it as ruby@apPath.to_s
etc... or wrap it for a system call like this
(
open -n $"#{@apPath}"\n)
I think that's very handy, john -
@driven said:
Still not wrapped, as I think I'll add it to my ON_OFF.rb and rework that to add a few new tricks this exercise has exposed.
However, this is now running in either of the two versions of SU I have installed at different Paths, and it should also add your native Ruby and Gem Paths on >1.8.5 [gems don't work on 1.8.5 unless you still have a full instal of both...]
[attachment=0:28ht225z]<!-- ia0 -->rubyVersion_change.rb<!-- ia0 -->[/attachment:28ht225z]
Should I delete all the other progression code? I did edit it to work, and it has a variety of other methods...John,
Lots of problems with this code on my Mac. I'm pressed for time right now, will PM you later when I get a chance.
Steve
-
There's 2 potential problems I can see, the first is my need to check which version of SUv8 I'm using, as they share .plist, so I've re-coded all that and this should return the correct path regardless of version.
Works without the hard coded version numbers on mine.
If it does you could just swop it in and test further, or let me know.@SUversion=(Sketchup.version.to_s) stndSU=("/Applications/Google\ SketchUp\ 8/SketchUp.app") altSU=("/Applications/SketchUp.app") chkSU=("/Applications/Sketchup.app/Contents/Info.plist") if File.exists? chkSU f=(IO.readlines chkSU) k=(f.index "\t<key>CFBundleVersion</key>\n").to_i v=(k + 1) s=(f[v]).gsub("<string>","").gsub("</string>","").strip end if s === @SUversion @apPath=(altSU) else @apPath=(stndSU) end #if @apPath.freeze @verPath=("/Contents/Frameworks/Ruby.framework/Versions") @ourPath=(@apPath.to_s + @verPath.to_s)
The second problem could be your permissions, which I can't check easily, but I could have a conditional that fails gracefully.
john
added@SUversion=(Sketchup.version.to_s)
as first line so this should run as a standalone, it's already in the ruby... -
Update to the community: driven and I have got a plugin to do this Ruby swap nearly ready. Currently kicking it around to shake out any remaining bugs and packaging it for distribution. We'll put in the plugins forum soon.
Steve
-
Just playin' devil's advocate:
Must the switch be done from within SketchUp, requiring a restart... or can desktop shortcuts (aka symbolic links, for you unix-like peeps,) be created to start SketchUp running whatever Ruby version is desired ?
(I had asked this question long ago, in a similar topic thread.)
-
@dan rathbun said:
Just playin' devil's advocate:
Must the switch be done from within SketchUp, requiring a restart... or can desktop shortcuts (aka symbolic links, for you unix-like peeps,) be created to start SketchUp running whatever Ruby version is desired ?
(I had asked this question long ago, in a similar topic thread.)
Our switchover plugin is from within SketchUp and does require a restart (which it performs automatically for you). To select the version at launch time, you'd need to wrap it in a shell or Apple script that performs the shell commands I provided earlier. I don't think there is any way to tell SketchUp itself which Ruby to use as it launches...it behaves like it has a path to its distributed version coded into the executable.
Steve
-
@dan rathbun said:
Just playin' devil's advocate:
so unlike you,
Dan at the time I made a few external auto_SU function menu items, no one was interested unless there inside SU, or maybe in an external editor menu.
Main reason given was they didn't want to see SU Tools if they're not using SU... which is fair enough.
I've pulled the 'reload part' out as a separate button[still in SU], and I use that all the time when testing stuff, sometimes I swap ruby versions first, sometimes I turn plugins on/off then 'reload SU' as a one click.
I like it
john -
@slbaumgartner said:
To select the version at launch time, you'd need to wrap it in a shell or Apple script that performs the shell commands I provided earlier.
Obviously.. same on Win. It runs a bat/cmd script and launches SketchUp as it's last statement.@slbaumgartner said:
I don't think there is any way to tell SketchUp itself which Ruby to use as it launches...
FWIW & FYI ... I have previously entered a Feature Request to do just this. I suggested a config file of some kind .ini format (Win) or .plist (Mac.), I may have even mentioned a JSON object file, which would likely be best.Hmmm... I might have even suggested a "special set" of environment vars using the prefix "SURE" instead of "RUBY"... ie SUREPATH instead of RUBYPATH, SURELIB instead of RUBYLIB, etc. I like the second idea even better, as we can use RVM (on Mac) and pic (on Win) to install (including gems,) maintain, and switch between multiple Ruby versions.
@slbaumgartner said:
... it behaves like it has a path to its distributed version coded into the executable.
Which it does at least on Windows, ... or just specifies the DLL without a path, meaning it must be in SketchUp's own bin directory on Windows. (I know it's in a Framework subdir on Mac.) -
Still not wrapped, as I think I'll add it to my ON_OFF.rb and rework that to add a few new tricks this exercise has exposed.
However, this is now running in either of the two versions of SU I have installed at different Paths, and it should also add your native Ruby and Gem Paths on >1.8.5 [gems don't work on 1.8.5 unless you still have a full instal of both...]
[highlight=#ff40bf:1hf3halj]REMOVED ATTACHMENT as dan and Steve and I seem to be the only players, and a new version is being tested[/highlight:1hf3halj]
Should I delete all the other progression code? I did edit it to work, and it has a variety of other methods... -
Background.
This issue has been discussed for at least 2 years.
Here's a thread I participated in, that began in 2010:
-
WARNING
Make sure to restore SketchUp to its distribution Ruby (1.8.5) before installing a version update to SketchUp! Otherwise the SU install will overwrite parts of your system-installed 1.8.7 Ruby and make it unusable (DAMHIKT)!
Steve
Advertisement