We have a Rails application (2.2.2) running on a Tomcat7 server using warbler (1.2.1) and JRuby (1.5.6), but since we want to simplify the deployment on several machines, we want to run rake tasks like db:migrate , under the WEB-INF location of tomcat. We packed the db folder along with all the migrations.
One of the ways we saw on the Internet does not 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 ran:
jruby -S $JRUBY_HOME/bin/rake db:migrate RAILS_ENV=staging
I get a large column of gem errors resulting from the sale of gems. (OutOfMemoryError, NUllPointerException, etc., Which is not really consistent between runs).
This question ( How do I run rake rake tasks in a rails application that is served by tomcat with jruby war deployment? ) Also has no bites. Any suggestions are welcome.
Greetings.
Glenn source share