Support for Gems with Native Extensions?
-
Hi all,
Please forgive my newbieness/ignorance, but are there any plans or is anyone working on support for Gems that require Native Extensions?
I know the complexities (I've been investigating for kicks this weekend) but this would be a huge boon for Ruby developers. I was specifically aiming to install nokogiri and have been experimenting over the weekend with little success.
Additionally there appear to be quite a few files missing from the Std-lib. mkmf.rb and the irb files are notable. I can guess why as to the irb files weren't included but I'm curious about the rest of them. Can anyone shed some insight here for me?
-
Some part of the Ruby Standard library would crash SketchUp because it made adduption about Ruby being run as a Console app instead of being embedded as it is in SketchUp. So we removed those modules to avoid inadvertent crashes.
"Native Extensions" you mean Ruby C Extensions?
We have example Visual Studio and Xcode project for this on GitHub:
https://github.com/SketchUp/ruby-c-extension-examplesWhat challenges did you have with Nokogiri?
-
On Mac OS X, even with XCode and command line developer tools installed, the SU installation of Ruby is not set up to enable compiling and installation of most C-library Gems. For example, one Gem I attempted assumed that there was an executable Ruby interpreter in the SU Ruby Framework where the Gem library lives (there is not - only the dynamic library loaded by SU). Fixing this requires loading a 32-bit Ruby compatible with SU, since the native installation is 64-bit. But even then the generated Makefile and other scripts fail due to problems with configuration. For example, Ruby was launched with an illegal command line option to one of the install scripts. In the end I hand-edited things and got the Gem to compile and install, only to discover as TT points out that SU's Ruby intentionally omits certain standard library components that were found to crash SU.
Bottom line: with enough determination you can build a compiled-C Gem, but don't be surprised if libraries it wants are missing or if it BugSplats SU!
Steve
Advertisement