Dan Stutzman

Missing hooks/after_use_jruby_opts file

Published 2012-01-25

After joining a JRuby project that used RVM and had an .rvmrc file in source control, I noticed the following error message when I cd'd into the project directory:

chmod: /Users/dstutzman/.rvm/hooks/after_use_jruby_opts: No such file or directory

So what was calling the chmod command and why was ~/.rvm/hooks/after_use_jruby_opts missing? It turned out that the problem was coming from a manual insertion made to .rvmrc recommended by a stackoverflow post :

          # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
          chmod +x ${rvm_path}/hooks/after_use_jruby_opts

So that explains where chmod command came from, but why was the ~/.rvm/hooks directory present on the original developer's machine, but not mine?

The answer is that my version of RVM was older than the version the original developer was using. To update it, I followed RVM's upgrading instructions by running rvm get latest. That created a ~/.rvm/hooks directory so the error disappeared.

More importantly, the RVM upgrade fixed a much bigger problem: that JRuby was running in Ruby 1.8 mode instead of Ruby 1.9 mode. Setting PROJECT_JRUBY_OPTS with the addition noted above was supposed to fix this problem, but it didn't. We could prove that JRuby was still running in Ruby 1.8 mode because running the following command using Ruby 1.9 syntax:

jruby -e 'p({ a: 3 })'

...produced the following error:

SyntaxError: -e:1: syntax error, unexpected ':'

Fortunately, upgrading RVM got PROJECT_JRUBY_OPTS working again, so running that same command was the same as running:

jruby --1.9 -e 'p({ a: 3 })'

...and produced the expected output:


It would be nice if the PROJECT_JRUBY_OPTS code snippet would have tested the version of RVM and complained about it directly, but I suppose the No such file or directory error was better than nothing.

TL;DR Before sharing a customized .rvmrc, update RVM