Thanks a lot Thom. I will definitely give it a try.
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?
I am having same issue with ruby clipper.
@Sketchup team: kindly let us know how to resolve this.
I don’t think SketchUp officially supports (or can support) Ruby gems. (And if, more problems would arise since developers would start publishing extensions which require gems which require build tools which are unfortunately not naturally shipped by the user’s OS if you target Windows.)
When you search the forum you find: If a gem works, it is fine to use. But you must not use
Gem.install (slow, freezes SketchUp) in your extension, and wrap the copied gem into your namespace.
Regarding the error
The 'clipper' native gem requires installed build tools, does your PATH environment variable contain the correct path to devkit? If not, you must add it. If it is, is it correct? Does Ruby see that environment variable (in SketchUp:
Question I’ve never asked. Given that recent SU versions have used Ruby 2.0, 2.2, & 2.5, can one compile extension gems (for all three versions) on MacOS as is, or does one need to install matching stand-alone Ruby versions for each?
This really isn’t about what the Sketchup team can do. There are all sorts of potential problems when using gems with SU. These problems can exist with both ‘plain Ruby’ gems and especially with extension gems.
There are work arounds, but they are very dependent upon the use case.
Re the clipper gem, there have been two releases, one in Dec-2010, the other in Jan-2014. The gem includes ‘Clipper’ 6.2.1, the current version is 6.4.2. If you can build & verify that it works in a stand-alone Ruby that matches the Ruby version used in the SU version you want to target, then people here may be able to help.
I believe the ‘Sketchup team’ should be responsible for their own API, and verifying that the Ruby installation works. Past that, add-ons to Ruby are the user/developers responsibility…
Thanks for your reply.
The latest Clipper version 6.4.2 is working in stand-alone Ruby version 2.5.1(Same as SU 2019 Ruby version). So, I can’t understand why the gem is not working in same Ruby version ?
And the error message(the specified module not found) is generic and very high level, not enough to debug further deep into it. So, I am requesting SU team to look into this.
Do you mean: It installs in stand-alone Ruby (with
gem install), and the gem installer sees the build tools path and finds the build tools.
Some of this is probably not working in SketchUp with
Or do you mean you transfered the gem’s built code into your extension and wrapped it into your namespace (because of: “clipper: Builds a native ruby extension for Clipper”) and it is not loading in SketchUp?
See my reply in this thread: Install Prawn gem in SketchUp 2016
TL;DR: Gems are not something we support. If you want to use them for extension you distribute, please fork it and wrap it under your own namespace.
This tends to be due to incompatible binary. Often its related to linking to an incompatible Ruby builds (version or bitness). You might want to inspect the symbols being export. And check what Ruby DLL it links with.
Well, since you bolded it, please explain where you see version 6.4.2?
The current gem is 2.9.1, and the repo for it has been updated to 184.108.40.206, but it has not been released.
And the error message( the specified module not found ) is generic
Normally, this refers to a dll that can’t be found. clipper.so links to
libstdc++-6.dll, which should both be included with SketchUp 2019, which I do not have loaded.
You might try adding your msys64/mingw64/bin path to
ENV['PATH'] in the SU ruby console, then requiring the clipper file.
I decided to install the SU2019 trial version and see if anything has changed. IMO:
- There are dll’s missing that should be included.
- There are duplicate dll’s.
- Re gems, a handy thing to do is install gems from stand-alone using
--user-install, then the gems should be available in SU. They are not.
- The ridk runtime has been removed.
- It seems all bundled gems have been removed. Several are cli based and don’t really have a use in an embedded Ruby. But the test gems and XMLRPC could have been included. I’ve never tried using rake from script…
- RbConfig isn’t set up correctly.
There’s probably more, I haven’t really gone thru it. For one thing, why didn’t it ship with 2.5.3? The ABI is the same, and nothing is ever removed within a minor release, and, since the patch jumped from 57 to 105, that’s quite a few bug fixes. On windows, 2.5.1 shipped with OpenSSL 1.1.0, 2.5.3 shipped with 1.1.1, which is a LTS version…
I try to look at SU from the perspective of a Ruby coder brought into a small business that wants to integrate SU with their other software. If I was that coder, I’d be irritated.
So, there are things that the ‘Sketchup team’ could improve on. FWIW, I built clipper and it’s loading in SU…
Which DLLS are missing?
What are the bundled gems missing?
We had to strip out some extra modules in 2.5 as we found some of them was under licenses we could not redistribute. But majority of those appeared to be related to CLI so it didn’t look to have much of an impact.
Testing - every change require more testing. 2.5.1 was the latest one when we made the upgrade.
Which DLLS are missing?
Took more work than I thought:
libgcc_s_seh-1.dll libgdbm_compat-4.dll libgdbm-4.dll libiconv-2.dll libintl-8.dll libreadline7.dll libstdc++-6.dll libtermcap-0.dll
What are the bundled gems missing?
The test gems would be helpful. Also, there is not a single gemspec file that I can find. These should be included.
Testing - every change require more testing.
Being pretty familiar with Ruby testing, Ruby 2.5 was the first version fully tested on Windows.
The two main test suites were added in this commit on 2017-Jun-07, which was an mswin build. At the time, I was doing full MinGW testing in ruby-loco.
Full testing on MinGW builds was added with this commit on 2018-Aug-18. Granted, this doesn’t mean that issues can’t arise in SU, but I think it’s a pretty good indication that they’re unlikely, especially within a minor version. There are tests that specifically test the ABI. And finally, Ruby Core is starting to add testing on MacOS (previously it was just Ubuntu). As mentioned above, a teeny release (2.5.x) is bug fixes, so 2.5.3 should present fewer issues than 2.5.1, and due to updates in MSYS2/MinGW, there are several updated ‘dependency packages’ used in MinGW builds.
Finally, I’ve attached them before, but attached is zip file that includes two files,
su_info.rb shows info about the Ruby installation, similar to code I’ve got running on Appveyor & Travis.
su_gem.rb is a utility that allows one to use gem commands from the SU console (see comments in file). Two in particular are
SUGem.list. There are additional files, they are used for the SSL testing. I could make them a GH repo…
su_utils.zip (12.3 KB)
Since I have tried many ways to bundle clipper, but not succeeded. Can you share the clipper file, which is loading in SU 2019 ?
The version 6.4.2 is the source version (from: https://sourceforge.net/projects/polyclipping/files/latest/download).
There’s a couple of ways I can do this, let me think about the best way. A couple of things:
The link above is to the c source, the gem ‘clipper’ is a wrapper around it. The current gem is on a very old version of the c source.
You do have a working stand-alone Ruby 2.5.1? Do you have the ‘DevKit’ installed? If your system responds to
ridk version, it is installed. I will need you to post the output of that to get clipper working on your system. Change names if you want…
The ‘clipper’ gem wrapper code/repository is using the c source v 6.2.1, but as mentioned above, it hasn’t been released as a gem. There are no tests in the GitHub repository, so I can’t easily tell if the build works with the newer versions of the c source…
I’m going to see if I can build it with 6.4.2 or 6.2.1, which may take a little while, but then others can use it. I’ll probably do that on Appveyor.
I may also throw together a GitHub repo with code & docs for how to set up SketchUp to correctly work with gems.
Well, I ended up finding a gem called ‘polygon_clipper’, which did seem to have the participation of the 'rbclipper` author. So, I’ve compiled a clipper gem that is using Clipper 6.4.2. It can be used with Ruby 2.2.x thru 2.6.x. Below are the steps to install it:
1. From stand-alone Ruby 2.5.1, enter
ridk version in a command or PowerShell window. You’ll see:
msys2: path: C:\msys64
Add mingw64\bin to that path, and find two files there:
These files need to be added to:
C:\Program Files\SketchUp\SketchUp 2019
A complete list of the missing dll’s is above, but just these two are needed for clipper.
2. Also above is a file in a message of mine called
su_utils.zip. You need to download it and extract it somewhere. The file you’ll need is
3. The pre-compiled gem needs to be downloaded, the file is:
4. Now, you’re ready to do something in SketchUp. The following are the steps I did in the SketchUp console (prefixed by
>) and the output from them. Anywhere I’ve shown
<path>, you need to substitute the correct location:
> require '<path>/su_gem.rb' true > SUGem.install '-lN <path>/clipper-220.127.116.11-x64-mingw32.gem' Successfully installed clipper-18.104.22.168-x64-mingw32 1 gem installed > require 'clipper' true > Clipper::VERSION 22.214.171.124 > Clipper::Clipper.instance_methods(false).sort.join "\r\n" add_clip_polygon add_clip_polygons add_subject_polygon add_subject_polygons clear! difference intersection multiplier union xor
None of the ‘clipper’ repositories have tests, and I haven’t checked to see if it works. The methods that it should be defining are showing up, so that’s as far as I went…
Thank you so much for your help and support.
I tried these steps and got the following error while requiring clipper
The installation is successful, but require ‘clipper’ giving the following error.
Error: #<LoadError: 193: %1 is not a valid Win32 application. - C:/Users/Arjun/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Gems64/gems/clipper-126.96.36.199-x64-mingw32/lib/2.5/clipper.so>
require_relative' C:/Users/Arjun/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Gems64/gems/clipper-188.8.131.52-x64-mingw32/lib/clipper.rb:1:in <top (required)>’
C:/Program Files/SketchUp/SketchUp 2019/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:59:in
require' C:/Program Files/SketchUp/SketchUp 2019/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:59:in require’
Kindly help me on this.
I tried what you’ve got listed above, and although I had a different error, it didn’t load, you might try double quotes after adding the file below…
Sorry, I didn’t trace the dlls enough. Just like the two files you copied, you need to add
Yep, this is working…
Thank you so much for your timely help.