I’m trying to load the FFI gem version (ffi-1.9.17-x64-mingw32) in Windows 10, Sketchup 2017 (maintenance build - 17.2.2555).
Edit note: In my old post, I had only loaded the ffi_c.so file corresponding to ruby version 2.2 and I can see that was incomplete frm FFI perspective, and hence now loaded the whole of FFI gem.
As I execute the below command of getting a memory pointer, SketchUp throws a bug splat…
(1) Instructions on properly formatting error text in the forum ...
Your error report text is incorrectly formatted for the forum. (The forum engine stripped out the error message because it thought it was an invalid HTML element bracketed between < and > characters, which I’ve escaped with leading \ here.)
Please edit (pencil icon) your post, and insert triple backtick delimiter lines, before and after the error text block. (The backtick key is to the left of the 1 key just above the TAB on US keyboards):
```text # error text here
```
(2) SketchUp comes with it’s own specially compiled edition of Ruby and the standard library.
I would advise you to use the Fiddle library that comes with SketchUp’s Ruby library.
Loading “fiddle.rb” will load “fiddle.so” which loads
“SketchUp 20nn/Tools/RubyStdLib/platform_specific/libffi-6.dll”
most likely using a LoadLibrary call. Since Ruby is all opensource, you can read the source: ruby/ext/fiddle at ruby_2_2 · ruby/ruby · GitHub
Thanks for the tip on error text Dan, I have edited my above post.
and on Fiddle,
Yes we are aware of fiddle as alternate, but we have a big library built on top of FFI, and we are in a stage to release the product in Sketchup 2017 but this FFI bug splat is like a show stopper for us now. Re-writing our library in fiddle might take some amount of time, we are trying to see if there is something from our side which can be fixed on this bug splat case.
FFI in 2017+Win 7 combination works just fine,
FFI in 2016 + Win 10 Combination works fine
FFI in 2017 + Win 10 => Bug splat
If this is a Sketchup-only-fix-able issue, we will move on with fiddle option…
FYI, Gems for SketchUp are installed in a SketchUp specific location (purposely kept separate from any “system” Ruby installations.)
From inside SketchUp’s Ruby console you can see the location via:
puts ENV["GEM_HOME"]
puts ENV["GEM_PATH"]
OR
require "pp"
pp ENV
The folder name is “Gems” for 32-bit installations, and “Gems64” for 64-bit installations.
BUT, … this only works well for pure Ruby gems.
SketchUp Ruby and it’s rubygems extension, is not linked up with Ruby’s DevKit, so cannot compile C gems “on the fly” like a normal “system” Ruby install (with the proper DevKit) can.
Sometimes what coders do is provide precompiled 32-bit and 64-bit gems, that are repackaged as a SketchUp extension, or as support libraries within their extension. It may be helpful to tweak the gem namespace(s) so that they are encapsulated inside your toplevel author (or company) namespace module.
We have discussed this both here (in this category) and over at SketchUcation in the Developers forum.
It would be so nice to communicate with Arduino straight from SketchUp… ‘rubyserial’ requires ‘ffi’.
Well… I guess I will have to wrap C code for this myself.
Ah, never noticed this thread. And we don’t look over all BugSplats submitted.
Best thing to report an issue like this is the bug tracker as that get scrubbed regularly.
(EDITED: To remove mention of Nokogiri, as it does not depend upon the FFI gem.)
Users of Fiddley need to uninstall the ffi gem. This is because the normal loading call …
require "ffi"
… needs to load "#{ENV["GEM_HOME"]}/gems/fiddley-0.0.8/lib/ffi.rb"instead of the "ffi.rb" that comes with the ffi gem.
Just a note, (after moving the ffi gem to an “off” folder from the "gems" folder, and moving it’s .gemspec archive out of the "specifications" folder,) … I tried the OP’s test using just Fiddley …
I’m likely mistaken. I thought the FFI wiki mentioned that Nokogiri used the FFI gem. (But I’m probably confusing with the Racc lib that was recently [and temporarily] removed from the SketchUp distribution.)
FFI Github wiki: Projects using FFI
… does not mention Nokogiri (nor does the Nokogiri RubyGems page,) so I’ll remove that phrase from the post above.