Ruby Version for Sketchup 8.0 M1 on Mac ??
-
@slbaumgartner said:
Hmm...there is a school of though that says ordinary users shouldn't be able to tamper within the subfolders of an app bundle, since they can destabilize the app in arbitrary ways.
I've never considered myself ordinary maybe ornery
@unknownuser said:
On a more basic level, after switching to 1.8.7, why would someone want to switch back?
I was thinking that this would be more for Dev's and/or the curious, and if you add an -n flag, to the open cmd you can have both at once in two separate instances of Sketchup.
@unknownuser said:
So far, I haven't run into any old ones that won't run on 1.8.7.
Well, oddly enough the code I first had for this, would only work from 1.8.5 >> 1.8.7 but not back down.
It took me ages to find the same layout that would work in bothThread.new
requires a block in 1.8.7, but will work in 1.8.5 with or without.@unknownuser said:
you have to use RUBY_VERSION to get the right string.
Steve
I always do, i didn't realise VERSION would work at all until you posted it...
john -
@driven said:
@slbaumgartner said:
... you have to use
RUBY_VERSION
to get the right string.
I always do, I didn't realizeVERSION
would work at all until you posted it... johnFrom the Ruby v1.8.6-p398 API Core Reference, for
Object
constants:
The caption "obsolete constants" is supposed to be in a right margin, but the DarkFish doc generator didn't do that. It shoved the right margin text under the first item in the left column.A check of the online doc for v1.9.x shows they have finally been removed.
see: Ruby Core v1.9.3: Object -
Dan,
I find those parts of the Ruby documentation ambiguous, as the phrase "obsolete constants" displays below VERSION when I view the page, as if, in the example you posted, it applies to RELEASE_DATE and PLATFORM but not to VERSION. In any case, it is clear that we should use RUBY_VERSION as there are examples on the table where using VERSION breaks
Steve.
-
Hi Steve,
just got back and tested your method, works a treat, so I worked out a Ruby Console 'none sudo' version that works here, if it works for you I'll make it into a toggle button for switching from inside SU...# Thread #1 is running here newRuby = Thread.new{ # Thread #2 runs this code `cd /Applications/Sketchup.app/Contents/Frameworks/Ruby.framework/Versions mv A A.orig ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8 A cd / open /Applications/Sketchup.app ` } # Thread #1 runs this code if RUDY_VERSION == "1.8.5" newRuby Sketchup.send_action('terminate;') end # Thread #1 is running here oldRuby = Thread.new { # Thread #2 runs this code `cd /Applications/Sketchup.app/Contents/Frameworks/Ruby.framework/Versions rm A mv A.orig A cd / open /Applications/Sketchup.app ` } # Thread #1 runs this code if RUBY_VERSION == "1.8.7" oldRuby Sketchup.send_action('terminate;') end
yes Dan I'll wrap it in a module...
john -
so, you need to double escape the system path, but single escape the ruby one.... aaahhhhhh
any testers, before I polish it?
puts "RUBY_VERSION = " + RUBY_VERSION # useful for debug... # Thread #1 is running here /Applications/Google\\ SketchUp\\ 8/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions def changeRuby 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 end #def toolbar = UI;;Toolbar.new "mac_RUBY_VERSION" # This toolbar toggles between 1.8.7 and 1.8.5 @mac_RUBY_VERSION = UI;;Command.new("change"){changeRuby; Thread.new{ # Thread #3 runs this code system("sleep 2 cd / open /Applications/Google\\ SketchUp\\ 8/SketchUp.app ") }; Sketchup.send_action('terminate;'); } @mac_RUBY_VERSION.large_icon = "/Applications/Google\ SketchUp\ 8/SketchUp.app/Contents/Resources/ReloadPage.png" @mac_RUBY_VERSION.small_icon = "/Applications/Google\ SketchUp\ 8/SketchUp.app/Contents/Resources/ReloadPage.png" @mac_RUBY_VERSION.tooltip = "Switch Ruby Version" @mac_RUBY_VERSION.status_bar_text = "Switching Ruby Version on reload" @mac_RUBY_VERSION.menu_text = "change_RUBY_VERSION" toolbar = toolbar.add_item @mac_RUBY_VERSION toolbar.show
-
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:
Getting SketchUp to play nicely with RubyGems?
-
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