So, I’ve just installed a fresh version of jruby 1.7.0 via rvm on my FreeBSD VPS and immediately wanted to see what would fail in my small app I was working on. Turns out I got this cryptic error:
WARNING: Error fetching data:
IOError: Function not implemented (http://rubygems.org/latest_specs.4.8.gz)
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
IOError: Function not implemented (http://rubygems.org/gems/bundler-1.2.0.gem)
Huh? That doesn’t make any sense… fortunately dmesg came to the rescue with this, more helpful message:
linux: pid 23484 (java): syscall epoll_create not implemented
Ah, right - I’m running in Linux emulation mode, the simplest (?) way to get Java running on FreeBSD. Fortunately for me it looks like the Java runtime has an alternative implementation of I/O based on poll(2). There are two ways to force the runtime to do that by setting the appropriate system property - either via the command line:
ruby -J-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider -S irb
or programatically:
> java.lang.System.setProperty('java.nio.channels.spi.SelectorProvider','sun.nio.ch.PollSelectorProvider')