sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Ruby Version for Sketchup 8.0 M1 on Mac ??

    Scheduled Pinned Locked Moved Developers' Forum
    41 Posts 6 Posters 3.6k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      slbaumgartner
      last edited by

      @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

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        Cheers,
        I'll have added the /usr/bin/irb/ $LOAD_PATH array to it by then...
        an auto version of this

        begin
        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

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          @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

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 Reply Last reply Reply Quote 0
          • S Offline
            slbaumgartner
            last edited by

            @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

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by

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

              learn from the mistakes of others, you may not live long enough to make them all yourself...

              1 Reply Last reply Reply Quote 0
              • S Offline
                slbaumgartner
                last edited by

                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

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  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.)

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    slbaumgartner
                    last edited by

                    @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

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by

                      @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

                      learn from the mistakes of others, you may not live long enough to make them all yourself...

                      1 Reply Last reply Reply Quote 0
                      • Dan RathbunD Offline
                        Dan Rathbun
                        last edited by

                        @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.)

                        I'm not here much anymore.

                        1 Reply Last reply Reply Quote 0
                        • D Offline
                          driven
                          last edited by

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

                          learn from the mistakes of others, you may not live long enough to make them all yourself...

                          1 Reply Last reply Reply Quote 0
                          • Dan RathbunD Offline
                            Dan Rathbun
                            last edited by

                            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?

                            😐

                            I'm not here much anymore.

                            1 Reply Last reply Reply Quote 0
                            • S Offline
                              slbaumgartner
                              last edited by

                              😲 😲 😲

                              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

                              1 Reply Last reply Reply Quote 0
                              • 1
                              • 2
                              • 3
                              • 2 / 3
                              • First post
                                Last post
                              Buy SketchPlus
                              Buy SUbD
                              Buy WrapR
                              Buy eBook
                              Buy Modelur
                              Buy Vertex Tools
                              Buy SketchCuisine
                              Buy FormFonts

                              Advertisement