Running rake commands from a unzipped war file #128

joshrendek opened this Issue Dec 18, 2012 · 2 comments


None yet

2 participants


rake db:migrate

sudo RAILS_ENV=production BUNDLE_WITHOUT=development:test BUNDLE_GEMFILE=Gemfile GEM_HOME=gems java -cp lib/jruby-core-1.7.1.jar:lib/jruby-stdlib-1.7.1.jar:lib/gems-gems-activerecord-jdbc-adapter- org.jruby.Main -S rake db:migrate

Is an example of how to run rake db:migrate -- @headius and atambo on IRC helped me figure this out.

Perhaps an easier way to do this in the future :)?

Loading rails models/application in irb

To load your rails application... use irb instead of rake db:migrate, and then:

APPLICATION_NAME::Application.initialize! in the console to get all your models, etc loaded.

Creating a user

Still stuck on this portion -- BCrypt error

source ''

# Use unicorn as the app server

# gem 'unicorn'
gem 'rails', '3.2.8'

platforms :jruby do 
  gem 'activerecord-jdbcmysql-adapter'
  # gem 'jruby-openssl' # not neededing 1.7.x
   gem 'warbler'
   gem 'json'

platforms :ruby do 
  gem 'mysql2'
  gem "thin"

gem 'rake'
gem 'jquery-rails'
gem 'bourbon'
gem 'rails_autolink'
gem 'state_machine'
gem 'devise'
gem 'cancan'
gem 'foreman'
gem 'redis'
gem 'dalli'
gem 'kaminari'
gem "whenever", :require => false
gem 'rabl'
gem 'tire'
gem 'tire-contrib'
gem 'json'
gem 'rest-client'
gem 'valium'
gem 'carrierwave'
gem "resque" #, :git => ""

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'

  platforms :jruby do 
    gem 'therubyrhino'


group :development do
  gem "capistrano"
  gem 'capistrano_colors'
  gem 'annotate'
  gem 'awesome_print'
  gem 'bullet'
  gem 'quiet_assets'
  gem 'pry'
  gem 'pry-rails'
  # gem 'pry-debugger'
  # gem 'pry-stack_explorer'
  gem "spork-rails"

group :test do
  gem 'shoulda-matchers'
  gem "capybara"
  gem "capybara-webkit"
  gem 'database_cleaner'
  gem 'simplecov', :require => false
  gem 'timecop'
  gem 'resque_spec'

group :development, :test do
  gem "rspec-rails"
  gem 'factory_girl_rails'
  gem 'progress_bar'
  gem 'launchy'
  gem "guard"
  gem "guard-rspec"
  gem 'faker'
  gem 'simplecov', :require => false

JRuby Team member

so here's my sleeping biuty gem from my dropbox
it's built from my exec-war branch on my warbler fork - but I'm not sure I merged correctly ...

it kind of auto-extracts the .war into a /tmp dir and runs from there while isolating from the ENV :

  • gem install
  • warble executable war
  • java -jar YOUR.war -S rake db:migrate
JRuby Team member

and so it works for me (on Linux) while not having a jruby around even using your Gemfile (using mysql as the DB) :

kares@theborg:~/workspace/github/jruby-rack/examples/rails32$ rvm use system
Now using system ruby.
Running /opt/local/rvm/hooks/after_use_jruby_opts
kares@theborg:~/workspace/github/jruby-rack/examples/rails32$ jruby -v
The program 'jruby' is currently not installed. You can install it by typing:
sudo apt-get install jruby

kares@theborg:~/workspace/github/jruby-rack/examples/rails32$ java -jar rails32.war -S rake db:migrate==  CreateDelayedJobs: migrating ==============================================
-- create_table(:delayed_jobs, {:force=>true})
   -> 0.0280s
   -> 0 rows
-- add_index(:delayed_jobs, [:priority, :run_at], {:name=>"delayed_jobs_priority"})
   -> 0.0260s
   -> 0 rows
==  CreateDelayedJobs: migrated (0.0570s) =====================================

==  DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
   -> 0.0160s
   -> 0 rows
-- add_index(:users, :email, {:unique=>true})
   -> 0.0280s
   -> 0 rows
-- add_index(:users, :reset_password_token, {:unique=>true})
   -> 0.0630s
   -> 0 rows
==  DeviseCreateUsers: migrated (0.1100s) =====================================

although I do expect issues (esp. with other commands such as rails console) it's better than nothing I'll try to clean things up and open a PR

@kares kares closed this Apr 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment