Make runnable respect config.webxml.jruby.compat.version
I really appreciate the work on this 'runnable'. I had some ruby scripts to do this work and they were working ok, but did not work with the bundled git gems.
I am having a problem because I don't think the runnable is respecting:
config.webxml.jruby.compat.version
error: org.jruby.exceptions.RaiseException: (RubyVersionMismatch) Your Ruby version is 1.9.3, but your Gemfile specified 1.8.7
Can this be added please. I must be in the extreme minority still supporting a 1.8.7 app.
CC: @kares @bjeans @BanzaiMan
I read the source and it says:
/**
* jruby arguments, consider the following command :
* `java -jar rails.war --1.9 -S rake db:migrate`
* arguments == [ "--1.9" ]
* executable == "rake"
* executableArgv == [ "db:migrate" ]
*/
I try: java -jar my_app.war --1.8 -S script/console
And get:
error: org.jruby.exceptions.RaiseException: (RubyVersionMismatch)
Your Ruby version is 1.9.3, but your Gemfile specified 1.8.7
Did you try with either of these in the warble.rb file?
config.webxml.jruby.compat.version = '1.8'
config.webxml.jruby.runtime.arguments = '--1.8'
Thanks for your comment and efforts.
I did try the first line, that is what I put in the first issue comment. I tried this second line that you mentioned, but it didn't help.
error: org.jruby.exceptions.RaiseException: (RubyVersionMismatch) Your Ruby version is 1.9.3, but your Gemfile specified 1.8.7
When I try:
java -jar tartan.war --1.8 -S script/console
error: org.jruby.exceptions.RaiseException: (GemfileError) Gemfile syntax error file:/var/folders/d5/32b095kx7h18kjf4zf_4ptl5mmc9c1/T/jruby3542920198959500757extract/lib/gems-gems-jruby-jars-1.7.12-lib-jruby-stdlib-complete-1.7.12.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:548: syntax error, unexpected ':'
opt = {verify_mode: OpenSSL::SSL::VERIFY_PEER}.update(opt)
So it is pulling jruby.home/lib/ruby/1.9 instead of /ruby/1.8
not 100% sure but worth a try ... you might be able to work-around the issue by using a system property :
java -Djruby.compat.version=RUBY1_8 -jar tartan.war --1.8 -S script/console
Wow that works in executing in the correct 1.8 context.
Unfortunately it is not finding the gems and I get this
error: org.jruby.exceptions.RaiseException: (RuntimeError) Bundler couldn't find some gems.
Did you run `bundle install`?
So I am trying to hack META-INF/init.rb (based on this issue: https://github.com/jruby/warbler/issues/37) and it looks like this line is the problem:
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../WEB-INF/Gemfile', __FILE__)
I add some checks and after that ENV['BUNDLE_GEMFILE'] does not exist. Is there a difference in Ruby 1.8 and Ruby 1.9 behavior for expand_path or FILE that is causing this issue. It is obviously something with the relative paths, but I don't know how to fix it.
If you're building a .jar file instead of a .war, there's no way to set the Ruby version except via the java -Djruby.compat.version=RUBY1_8 workaround. You can't set config.webxml.jruby.compat.version because config.webxml is nil (which makes sense since there is no webxml file). Any chance that can be fixed? It's a problem for us at the moment.