We've got our Rails (2.2.2) application running on a Tomcat7 server using warbler (1.2.1) and JRuby (1.5.6), but since we want to simplify deployment to multiple machines, we want to run the rake tasks, like db:migrate
, under the tomcat WEB-INF location. We have packaged up the db folder along with all the migrations.
One way we've seen recommended online doesn't work:
java -jar lib/jruby-core-1.5.6.jar -S $JRUBY_HOME/bin/rake db:migrate RAILS_ENV=staging
/var/lib/jruby/bin/rake:9:in `require': no such file to load -- rubygems (LoadError)
from /var/lib/jruby/bin/rake:9
After adding to ENV:
GEM_HOME=$JRUBY_HOME/lib/ruby/gems/1.8
RUBYLIB=$JRUBY_HOME/lib/ruby/site_ruby/1.8
The same command gives:
/var/lib/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:32 warning: already initialized constant RAKEVERSION
/var/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require': no such file to load -- fileutils (LoadError)
from /var/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /var/lib/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:35
from /var/lib/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:31:in `require'
from /var/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /var/lib/jruby-1.5.6/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:29
from /var/lib/jruby-1.5.6/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:19:in `load'
from /var/lib/jruby/bin/rake:19
And if I just run:
jruby -S $JRUBY_HOME/bin/rake db:migrate RAILS_ENV=staging
I get a big callstack of gem errors resulting from the vendorized gems. (OutOfMemoryError, NUllPointerException, etc.. which isn't actually consistent between runs).
This question (How do I run rake rake tasks in a rails app which is served by tomcat with jruby war deployment?) had no bites on it either. Any suggestions are appreciated.
Cheers.
Turns out this command works
as long as I download the jruby-complete jar and make sure I have the ENV: