My default JRuby uses 1.9.3 mode. I added a .jrubyrc file to my project containing
Then I was able to do ruby -v and see it was in 2.0.0 mode. This verified that the .jrubyrc file was being read. I tried to install the ox gem, and got
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS or modify .jrubyrc to enable.
I tried closing my terminal, and re-opening, but still got the error. After I did export JRUBY_OPTS=-Xcext.enabled=true I was able to bundle the gem. So it seems the .jrubyrc file just ignored that option.
jruby 1.7.4 (2.0.0) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.6.0_51-b11-457-11M4509 [darwin-x86_64]
Remove mention of .jrubyrc for C Extensi building [skip ci]
Enabling C Extensions via `.jrubyrc` is not effective for building gems,
so remove the mention of it to avoid confusion.
The problem with the .jrubyrc approach is that, during gem installation, you would be in the fetched source's directory, not where you invoke jruby -S gem (or equivalent).
jruby -S gem
.jrubyrc does set the value correctly, but it just won't take effect when you want it.
$ cat > .jrubyrc
$ jruby -v -e 'puts ENV_JAVA["jruby.cext.enabled"]'
jruby 1.7.5.dev (1.9.3p392) 2013-08-15 25edb17 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_25-b15 [darwin-x86_64]
ah, ok. So really it only would work if that .jrubyrc was in my home directory, or something a bit more global as opposed to the project directory. Thanks!
This is an old thread, but I´m having trouble with .jrubyrc. I´ve put it in my home directory and it doesn´t seem to change anything. I actually want to change the java heap size.
@rbotafogo Please open a new issue if you're having problems with .jrubyrc on a current version of JRuby.