Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Make JRuby compatible with capybara-webkit (and possibly other gems) #4031
In the project I'm working on we've successfully been using Capybara with JRuby. We've considered switching drivers to Capybara WebKit as it is emerging as one of the faster Capybara drivers. In our case we have measured it is between 2 and 3 times faster (compared to Selenium/Firefox and Poltergeist/PhantomJS).
It has a quirk, though. It uses
There is this discussion: thoughtbot/capybara-webkit#725, but nothing seems to have come out of it. Further - a friend who develops this gem used to do something similar. Eventually he did fix his JRuby compatibility. But he did point me to libv8 which does it too. There are probably other examples out there of which I am not aware of.
Knowing that JRuby's goal is compatibility, I'd like to suggest the [re]introduction of
The major flaw that I can see in this pull request is that the error message:
The PR looks straightforward enough. I wonder, though...is there a better time for us to warn that C exts aren't supported than at compile time? I mean, it would be nice if mkmf still errored out once it became obvious that the gem contained an extension rather than a simple library.
I've thought about this too. The only thing I could think of was changing certain parts of
I am not familiar with the details of JRuby's usage of ruby's stdlib, though. Is it fine to keep source files with small changes in the "stdlib" directory? Or is there a place where stdlib code can be monkey patched?
this will most probably not work with JRUBY_HOME inside a jar, i.e. the jruby-complete.jar which is used my maven and gradle to install gems. this means some gems fail differently with jruby installation and those jar versions of jruby - if I understand this all right.
@mkristian I tested a bit. It behaves as I expect it to. I'm pasting some console output.
For some context - I'm on Windows (sorry for the windows command line) and capybara-webkit has a small issue that I have resolved locally. So I'm building and installing the gem from the local file system. I'm also using a freshly built jruby-complete located in
Building the gem works just fine...
C:\dev\capybara-webkit>java -classpath C:\dev\jruby\maven\jruby-complete\target\jruby-complete-188.8.131.52-SNAPSHOT.jar org.jruby.Main --command jgem build capybara-webkit.gemspec [.......... a bunch of warnings are printed .......] Successfully built RubyGem Name: capybara-webkit Version: 1.11.1 File: capybara-webkit-1.11.1.gem
C:\dev\capybara-webkit>java -jar C:\dev\jruby\maven\jruby-complete\target\jruby-complete-184.108.40.206-SNAPSHOT.jar --command jgem install capybara-webkit-1.11.1.gem ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared directory.
But once the
C:\dev\capybara-webkit>set GEM_HOME=C:\dev\jruby-gem-home C:\dev\capybara-webkit>java -jar C:\dev\jruby\maven\jruby-complete\target\jruby-complete-220.127.116.11-SNAPSHOT.jar --command jgem install capybara-webkit-1.11.1.gem Building native extensions. This could take a while... uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:56: warning: Tempfile#unlink or delete called on open file; ignoring Successfully installed capybara-webkit-1.11.1 1 gem installed
I've updated the PR with some changes. They are mostly in
As for my progress - it's been very limited. Long story short - I don't think it's possible to have adequate error messages on Windows.
My idea for the warning message was to let the configuration phase pass. And fail only when the actual Makefile is generated. The idea is to not limit people in the usage of the
What I did so far was test various gems with
So I'm thinking of switching environments to Linux and continuing there. This practically means Windows users will never see a clear message indicating that the issue is jRuby's lack of C extensions. Will that be acceptable?