Bundler::GemNotFound deploying with capistrano and rvm to a jruby enviroment

Recently I get this problem when deploying my project with capistrano to a jruby envrioment.

It raises the error Bundler::GemNotFound when it comes to the task deploy:assets:precompile

* executing `deploy:assets:precompile'
  * executing "cd /opt/app/deploy/entercamp/releases/20120627163015 && /usr/local/rvm/rubies/jruby-1.6.7/bin/jruby --1.9 -S bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile"
    servers: ["chicago"]
    [chicago] executing command
 ** [out :: chicago] Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources
 ** [out :: chicago]
 ** [out :: chicago] materialize at /usr/local/rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.4/lib/bundler/spec_set.rb:90
 ** [out :: chicago]
 ** [out :: chicago] map! at org/jruby/RubyArray.java:2371
 ** [out :: chicago]
 ** [out :: chicago] materialize at /usr/local/rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.4/lib/bundler/spec_set.rb:83
 ** [out :: chicago]
 ** [out :: chicago] specs at /usr/local/rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.4/lib/bundler/definition.rb:127
 ** [out :: chicago]
 ** [out :: chicago] specs_for at /usr/local/rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.4/lib/bundler/definition.rb:172
 ** [out :: chicago]
 ** [out :: chicago] requested_specs at /usr/local/rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.4/lib/bundler/definition.rb:161
 ** [out :: chicago]
 ** [out :: chicago] requested_specs at /usr/local/rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.4/lib/bundler/environment.rb:23
 ** [out :: chicago]
 ** [out :: chicago] setup at /usr/local/rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:11
 ** [out :: chicago]
 ** [out :: chicago] setup at /usr/local/rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.4/lib/bundler.rb:107
 ** [out :: chicago]
 ** [out :: chicago] (root) at /usr/local/rvm/gems/jruby-1.6
 ** [out :: chicago] .7@global/gems/bundler-1.1.4/lib/bundler/setup.rb:17
 ** [out :: chicago]
    command finished in 15575ms

But actually the gem is there, correctly installed and if you go to the server and run the command manually you will find it’s actually working.

This is a annoy problem. Yes, I could choose to run the assests:precompile and other stuff on manually on the server. But it would break the automation of capistrano and also would give downtime to the application so I decided to figure this out yesterday.

After a few experiments and with the help of Michal from rvm-capistrano project, it turns out that it’s because my jruby on server was compiled in 1.8 mode, and my project is running on 1.9. So when running the command, it is told to switch to 1.9 using --1.9 argument. And it could not find those gems.

The Solution I need to fix it with reinstalling my jruby on the server with 1.9 as default use the command: rvm install jruby-1.6.7.2 --1.9 or if you already installed, you could use rvm reinstall jruby-1.6.7.2 --1.9

You could find the whole story at: rvm-capistrano-issue-20 and I also filed an issue to jruby team: jruby-issue-219

Hope it helps.

comments powered by Disqus