Installing ruby gems in Sketchup


#1

Hi,

I have looked everywhere but I could not find a definitive answer.

Two simple questions:

  • Is it possible to install ruby-gems with ruby Sketchup (pro, >2014)?
  • Is there a recommended way to use a parallel ruby installation so that they do not mess up one another?

Thanks!


How can XML parse in ruby?
#2

http://ruby-doc.org/stdlib-2.0.0/libdoc/rubygems/rdoc/Gem.html

Gem.install "rubyzip"

Having said that, under Windows not all gems will install because some of them need to compile binaries. Under OSX this works out of the box because there is a system compiler available. But for Windows it usually require DevKit from Windows Ruby Installer to be on the system - not something end users will have installed, only developers. So you will find it a bit hit and miss to which one you can use on both platforms.

Under Windows you have the Windows Ruby Installer: http://rubyinstaller.org/
They also host the DevKit to build Ruby yourself.

Under OSX it’s much harder, but you have RVM: https://rvm.io/

But getting Ruby 1.8 i386 working on Mavericks is a pain. I eventually gave up.

If you want to compile Ruby C/C++ Extensions to be used with SketchUp use our Hello World example at GitHub: https://github.com/thomthom/ruby-c-extension-examples

It include the Ruby headers we use with SketchUp and set up with Visual Studio and XCode projects - matching what we use when building SketchUp.


#3

Thanks a lot Thom. I will definitely give it a try.


#4

Hi,

I managed to install Ruby 2.0 and Devkit from RubyInstaller.org. I also manage to install the gem that I need ‘rbclipper’.

In order to make it work I had to install the gem using the Ruby installation on Windows and then copy the rpclipper.so file in the SketchUp plugin folder.

I wasn’t able to use the suggestion from Thom: Gem.install “rbclipper” because i was getting the error

Error: #<Gem::InstallError: The 'clipper' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
>
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/defaults/operating_system.rb:12:in `rescue in block in <top (required)>'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/defaults/operating_system.rb:4:in `block in <top (required)>'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/installer.rb:244:in `call'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/installer.rb:244:in `block in run_pre_install_hooks'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/installer.rb:243:in `each'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/installer.rb:243:in `run_pre_install_hooks'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/installer.rb:209:in `install'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/dependency_installer.rb:372:in `block in install'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/dependency_installer.rb:332:in `each'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/dependency_installer.rb:332:in `each_with_index'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems/dependency_installer.rb:332:in `install'
C:/Program Files/SketchUp/SketchUp 2015/Tools/RubyStdLib/rubygems.rb:526:in `install'
<main>:in `<main>'
SketchUp:1:in `eval'

This works, but it looks more a workaround.

To me the problem seems to be that the Ruby Sketchup environment does not know where Devkit is, but I am not sure how to add the SU Ruby to DevKit in the config.yml file. There is no equivalent directory to C:\Ruby200-x64.

Am I missing something or this is just not possible and the work around is the way to go?

Thanks