Ruby Version for Sketchup 8.0 M1 on Mac ??
-
@driven said:
@dan rathbun said:
I don't have a Mac.. but there must be a way for you guys to point that link at your up to date "system" Ruby.
the path to version 1.8.5
/Applications/Google\ SketchUp\ 8/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/A/Ruby
but how to point it to system version??
check the Apple Help website on using, creating and editing symbolic links.
If you figure out how to do it.. post a "How To" here at SCF.
(Suggest if possible to back up the old symbolic link, before changing it.) -
@driven said:
what version is used on PC SU now?
Sketchup 8.0 M0 and M1 come "out-of-the-box" with v1.8.6-p287, but it is very easy to change that on PC by replacing the DLL (as long as it's in the 1.8 trunk.)
-
i want to extend the build_in sketchup interpreter too.
from the release note post by google here http://cfcl.com/twiki/bin/view/Projects/SketchUp/RE_Library_Use
Su 8.0 on pc has a 1.8.6 and a 1.8.5 on mac
the new 8.0 M1 release note says nothing about the ruby version. so i assume it is still the same.
here http://cfcl.com/twiki/bin/view/Projects/SketchUp/RE_Library_Use
Main.RichMorin post sth interesting. He also try to extend ruby inside su to other parts of the library, gems, etc.
it semms that he hasn't work it out yet.
but it's worth a try.
and i hope some gurus follow this path and somebody find a way eventually
note that even on pc it is 1.8.6 all right, but it has very limited access to the standard library and gems.
i try to use CSV class, but it fails. -
@wdbao said:
i try to use CSV class, but it fails.
See this post: http://forums.sketchucation.com/viewtopic.php?f=180&t=34381&p=302974#p302974
-
@dan rathbun said:
@wdbao said:
i try to use CSV class, but it fails.
See this post: http://forums.sketchucation.com/viewtopic.php?f=180&t=34381&p=302974#p302974
Thanks again! Dan!
you are a very good helper. and fast.
you have showed me this load path code before. i just couldn't understand it fully then. now with more ruby reading, it all make sense to me.
it feels great to be in a such nice community.
i will keep read on. -
@driven said:
@dan rathbun said:
I don't have a Mac.. but there must be a way for you guys to point that link at your up to date "system" Ruby.
the path to version 8.5
/Applications/Google\ SketchUp\ 8/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/A/Ruby
but how to point it to system version??
Not for the faint of heart, but here's how:
- quit sketchup
- open a terminal window
- cd /Applications/Google\ SketchUp \8/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions
- sudo mv A A.orig
- sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8 A
Restart SketchUp, open a Console window, and type VERSION. If all went well, it should report the same version as when you type ruby -e "puts VERSION" in a console window.
To undo this hack, in the same Versions folder:
- sudo rm A
- sudo mv A.orig A
-
Hi Steve,
I run as an admin, but not root, I need sudo for anything outside user space.
'Content' folders should have User read/write permissions, I thought.
I also run multiple copies of SU, the path for this one differs from norm and yours. [that may be the splat]the other thing I have now added sleep 1 and a return before the cd / to reopen SU in both methods.
I may have done blanket permission change using Sketchup.app >> right click >> more info and change for all enclosed files, but I don't think so... but that should work to avoid 'sudo'.
alternatively do that to your 'User' folder after installing SU there?just using the bits needed for a restart seems handy as well.
-
@John: The global constant
VERSION
is deprecated because every class and module should have one that specifies it's version, but if the global is defined, it will get inherited into every class and module, and it's easy to assume the inherited one is a specific module version.Example at the console:
module Dan; end %(#008000)[>> nil] Dan.module_eval("VERSION") %(#008000)[>> 1.8.6]
Oh look, module
Dan
is version 1.8.6 ?Not really:
Dan::VERSION %(#008000)[>> Error: #<NameError: (eval): uninitialized constant Dan::VERSION> (eval)]
Use
RUBY_VERSION
instead. (As well as the other constants that are prefixedRUBY_
... please.)
@Steve: Please don't quote codeblocks. Besides wasting space (and SCF bandwidth,) it just clones errors, and the original poster of the code may make corrections to the code, which will not be propagated into your quote. (I wish the quote feature would auto-strip them and insert a link back to the quoted post.)
(pssst... you can edit your post and delete the quoted code.)
-
@driven said:
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...yes Dan I'll wrap it in a module...
johnHi John,
On my Mac, the folders and files involved all have root ownership and rwxr-xr-x permissions, so without sudo I could change nothing. When I tried this script, SketchUp crashed (no bugsplat, just vanished!), and nothing changed. You aren't running as root are you? I can see how, after changing permissions, your script would be useful for toggling back and forth between versions, but I don't understand how it can work without either that tweak or sudo?
Steve
P.S. OK Dan, I deleted the code block
-
@driven said:
Hi Steve,
I run as an admin, but not root, I need sudo for anything outside user space.
'Content' folders should have User read/write permissions, I thought.
I also run multiple copies of SU, the path for this one differs from norm and yours. [that may be the splat]the other thing I have now added sleep 1 and a return before the cd / to reopen SU in both methods.
I may have done blanket permission change using Sketchup.app >> right click >> more info and change for all enclosed files, but I don't think so... but that should work to avoid 'sudo'.
alternatively do that to your 'User' folder after installing SU there?just using the bits needed for a restart seems handy as well.
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 once ran a utility that "fixes problems due to permissions", and I wonder if it reset the SU folders and files based on that thinking? Horse is out of the barn now, so without removing and reinstalling SU it's impossible for me to be sure. Maybe if another Mac user is watching this, they can look at their folders before either of our tweaks and tell us what permissions they see? The answer would be important so that your script could be shared successfully.
On a more basic level, after switching to 1.8.7, why would someone want to switch back? The only reason I have thought of is if you are writing plugins for the general Mac community, you might want to verify that they run on the as-installed SU with 1.8.5. So far, I haven't run into any old ones that won't run on 1.8.7. And if I do, provided they were distributed as open code, I'd be more inclined to fix them than to switch back to 1.8.5 just for their sake!
I had seen the problem Dan cites when I used the new Ruby console the Trimble guys posted on GitHub - VERSION on it returns 0.0.1; you have to use RUBY_VERSION to get the right string.
Steve
-
@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
Advertisement