jruby/warbler

warbler compiled failed case the wrong ruby version detected

plrthink opened this issue · 2 comments

I'm trying to compile a newly created rails app using this gem. But it fails with says 'Your Ruby version is 2.5.3, but your Gemfile specified 2.4.4'. Below is the full log and my env:

java -classpath "/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/jruby-jars-9.2.6.0/lib/jruby-core-9.2.6.0-complete.jar":"/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/jruby-jars-9.2.6.0/lib/jruby-stdlib-9.2.6.0.jar":"/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/jruby-rack-1.1.21/lib/jruby-rack-1.1.21.jar"  org.jruby.Main -S jrubyc  "app/channels/application_cable/channel.rb" "app/channels/application_cable/connection.rb" "app/controllers/application_controller.rb" "app/helpers/application_helper.rb" "app/jobs/application_job.rb" "app/mailers/application_mailer.rb" "app/models/application_record.rb" "db/seeds.rb" "config/application.rb" "config/boot.rb" "config/environment.rb" "config/environments/development.rb" "config/environments/production.rb" "config/environments/test.rb" "config/initializers/application_controller_renderer.rb" "config/initializers/assets.rb" "config/initializers/backtrace_silencers.rb" "config/initializers/content_security_policy.rb" "config/initializers/cookies_serializer.rb" "config/initializers/filter_parameter_logging.rb" "config/initializers/inflections.rb" "config/initializers/mime_types.rb" "config/initializers/wrap_parameters.rb" "config/puma.rb" "config/routes.rb" "config/spring.rb"
Your Ruby version is 2.5.3, but your Gemfile specified 2.4.4
warble aborted!
Compilation of .rb files failed (pid 11351 exit 18)
/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/warbler-2.0.5/lib/warbler/jar.rb:78:in `block in sh_jrubyc'
/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/warbler-2.0.5/lib/warbler/jar.rb:77:in `sh_jrubyc'
/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/warbler-2.0.5/lib/warbler/jar.rb:68:in `block in run_jrubyc'
/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/warbler-2.0.5/lib/warbler/jar.rb:60:in `run_jrubyc'
/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/warbler-2.0.5/lib/warbler/jar.rb:50:in `compile'
/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/warbler-2.0.5/lib/warbler/task.rb:109:in `block in define_compiled_task'
/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/warbler-2.0.5/lib/warbler/application.rb:79:in `run'
/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/warbler-2.0.5/lib/warbler/application.rb:74:in `run'
/Users/plrthink/.rvm/gems/ruby-2.4.4/gems/warbler-2.0.5/bin/warble:11:in `<top (required)>'
/Users/plrthink/.rvm/gems/ruby-2.4.4/bin/warble:23:in `load'
/Users/plrthink/.rvm/gems/ruby-2.4.4/bin/warble:23:in `<main>'
/Users/plrthink/.rvm/gems/ruby-2.4.4/bin/ruby_executable_hooks:15:in `eval'
/Users/plrthink/.rvm/gems/ruby-2.4.4/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => compiled => war:compiled
(See full trace by running task with --trace)
#Gemfile.lock
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.4.4'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.3.6'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
end

ruby: 2.4.4
rails: 5.2.2
bundler: 2.0.1
rvm: 1.29.3

I had a similar issue, I don't really understand why but Warbler seemed to pack a jruby-jars version in the generated war that didn't correspond to the jruby version I use on my system, and so the corresponding Ruby language versions didn't correspond neither.
To solve this :

  • I add the gem 'jruby-jars', '9.2.5.0' entry to my Gemfile. The version of the jruby-jars specified must be the one that correspond to your Ruby language version specified in your Gemfile. (in my case, jruby-jars 9.2.5.0 for Ruby 2.5.0)
  • Build the war running jruby -S bundle exec warble war. Using bundle exec will force Warble to use the correct jruby version specified in the Gemfile.

If you don't explicitly set the version of jruby-jars it will be determined by the Gemlock file which can be ahead or behind your jruby version. I usually put the variable jruby_jars_version at the top of the Gemfile so I know if it's out of synch with the jruby version I'm using.

jruby_jars_version = '9.2.11.1'

group :deploy do
  # For Warbler see: config/application.rb and config/environtments/production.rb
  gem 'warbler', require: false, platforms: :jruby
  gem 'jruby-jars', jruby_jars_version, require: false, platforms: :jruby
end