Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:45:01+00:00 2026-06-14T20:45:01+00:00

I just ran rake db:migrate directly on my server with no problems: $ pwd

  • 0

I just ran rake db:migrate directly on my server with no problems:

$ pwd
/var/www/vhosts/example.com/current
$ rake db:migrate

Then i tried to run it via a capistrano task and i get an error. The task and output are below. Why does rake db:migrate not work via my capistrano task?

task

namespace :deploy do
  # run the db migrations
  task :run_migrations, :roles => :db do
    puts "RUNNING DB MIGRATIONS"
    run "cd #{current_path}; rake db:migrate RAILS_ENV=#{rails_env}"
  end
end

cap deploy:run_migrations

$ cap deploy:run_migrations 
  * executing `deploy:run_migrations'
RUNNING DB MIGRATIONS
  * executing "cd /var/www/vhosts/example.com/current; rake db:migrate"
    servers: ["example.com"]
    [example.com] executing command
 ** [out :: example.com] (in /var/www/vhosts/example.com/releases/20121122011144)
 ** [out :: example.com] rake aborted!
 ** [out :: example.com] no such file to load -- rubygems
 ** [out :: example.com] /var/www/vhosts/example.com/releases/20121122011144/Rakefile:5:in `require'
 ** [out :: example.com] (See full trace by running task with --trace)
    command finished in 390ms
failed: "sh -c 'cd /var/www/vhosts/example.com/current; rake db:migrate'" on example.com

EDIT

$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
$ which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
$ which rails
/usr/local/rvm/gems/ruby-1.9.3-p125/bin/rails

EDIT
When i added –trace to the db migrations, it looks like it’s using /usr/lib/ruby/site_ruby/1.8/rake.rb, but from the looks of this:
$ which rake
/usr/local/rvm/gems/ruby-1.9.3-p125/bin/rake
i would have expected it to use rake at /usr/local/rvm/gems/ruby-1.9.3-p125/bin/rake rather than /usr/lib/ruby/site_ruby/1.8/rake.rb.

cap deploy’s output from the deploy:run_migrations task

* executing `deploy:run_migrations'
RUNNING DB MIGRATIONS
  * executing "cd /var/www/vhosts/example.com/current; rake db:migrate RAILS_ENV=production --trace"
    servers: ["example.com"]
    [example.com] executing command
 ** [out :: example.com] (in /var/www/vhosts/example.com/releases/20121123184358)
 ** [out :: example.com] rake aborted!
 ** [out :: example.com] no such file to load -- rubygems
 ** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/config/boot.rb:1:in `require'
 ** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/config/boot.rb:1
 ** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/config/application.rb:1:in `require'
 ** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/config/application.rb:1
 ** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/Rakefile:5:in `require'
 ** [out :: example.com] /var/www/vhosts/famnfo.com/releases/20121123184358/Rakefile:5
 ** [out :: example.com] /usr/lib/ruby/site_ruby/1.8/rake.rb:1828:in `load'
 ** [out :: example.com] /usr/lib/ruby/site_ruby/1.8/rake.rb:1828:in `load_rakefile'
 ** [out :: example.com] /usr/lib/ruby/site_ruby/1.8/rake.rb:1900:in `run'
 ** [out :: example.com] /usr/bin/rake:8
    command finished in 422ms
failed: "sh -c 'cd /var/www/vhosts/example.com/current; rake db:migrate RAILS_ENV=production --trace'" on example.com

EDIT
output after adding @Super Engineers code

* executing `bundle:install'
  * executing "ls -x /var/www/vhosts/example.com/releases"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 572ms
  * executing "cd /var/www/vhosts/example.com/releases/20121124160218 && bundle install --gemfile /var/www/vhosts/example.com/releases/20121124160218/Gemfile --path /var/www/vhosts/example.com/shared/bundle --deployment --quiet --without development test"
    servers: ["example.com"]
    [example.com] executing command
 ** [out :: example.com] You are trying to install in deployment mode after changing
 ** [out :: example.com] your Gemfile. Run `bundle install` elsewhere and add the
 ** [out :: example.com] updated Gemfile.lock to version control.
 ** [out :: example.com] 
 ** [out :: example.com] You have added to the Gemfile:
 ** [out :: example.com] * mysql2
 ** [out :: example.com] * therubyracer
 ** [out :: example.com] * rvm-capistrano
 ** [out :: example.com] * passenger
 ** [out :: example.com] 
 ** [out :: example.com] You have deleted from the Gemfile:
 ** [out :: example.com] * mysql
    command finished in 999ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/vhosts/example.com/releases/20121124160218; true"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 826ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p125' -c 'cd /var/www/vhosts/example.com/releases/20121124160218 && bundle install --gemfile /var/www/vhosts/example.com/releases/20121124160218/Gemfile --path /var/www/vhosts/example.com/shared/bundle --deployment --quiet --without development test'" on example.com

EDIT
Entire deploy.rb file

require 'bundler/capistrano'
require 'rvm/capistrano'

# set environment
set :rails_env, "production"

# set the ruby version
set :rvm_ruby_string, 'ruby-1.9.3-p125'
set :rvm_type, 'webadmin'

# server username and password
set :user, 'super'
set :password, 'secret'

# subversion repo username and password
set :scm, :subversion
set :scm_username, "super" 
set :scm_password, 'secret'
set :svnserver, "myreposerver" 
set :repository, "myrepo" 

# project info
set :server, ''
set :application, "FamNFo"
set :applicationdir, '/Volumes/Macintosh HD/Users/myname/Sites/example' 

role :web, "example.com"
role :app, "example.com"
role :db,  "example.com", :primary => true
set :use_sudo, true

# database config
#set :migrate_env, "#{rails_env}" 

# specify the rvm type. We just want to use the system wide one since we're not currently specifying gemsets for each project
set :rvm_type, :system

# where to put the files
set :deploy_to, "/var/www/vhosts/example.com" 

# fixes the "sorry, you must have a tty to run sudo" issue
default_run_options[:pty] = true

# precompiles the assets
load 'deploy/assets'

# If you are using Passenger mod_rails uncomment this:
 namespace :deploy do

    # restart the server
    task :restart, :roles => :app do
        run "/etc/init.d/http restart graceful"
    end

    # chmod the files
    task :after_update_code, :roles => [:web, :db, :app] do
        run "chmod 755 #{release_path}/public -R" 
    end

    # install new gems
    desc "run bundle install and ensure all gem requirements are met"
    task :install do
        run "cd #{current_path} && bundle install  --without=test --no-update-sources --trace"
    end

    # run the db migrations
    task :run_migrations, :roles => :db do
        puts "RUNNING DB MIGRATIONS"
        run "cd #{current_path}; rake db:migrate RAILS_ENV=#{rails_env} --trace"
    end

    # precompile assets
    task :precompile_assets do
        run "cd #{release_path}; bundle exec rake assets:precompile RAILS_ENV=#{rails_env}"
    end

    task :start do ; end
    task :stop do ; end

    # restart the server
    task :restart, :roles => :app, :except => { :no_release => true } do
        run "#{sudo} /etc/init.d/httpd restart graceful"
    end
 end

 # hook to run db migrations after code update
after("deploy:update", "deploy:run_migrations")
#after("deploy:update", "deploy:precompile_assets")
after "deploy:update", "deploy:install"
# if you want to clean up old releases on each deploy uncomment this:
after "deploy:restart", "deploy:cleanup" # leave the last 5 releases only
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:45:02+00:00Added an answer on June 14, 2026 at 8:45 pm

    Its because of ruby conflict. I’ve faced same error. You will need to use rvm/capistrano gem. I’ll paste some code from my cap file which will give you some idea about how to set the ruby version while deploying.

    install the gem

    gem install rvm-capistrano
    

    in you deploy.rb file add these lines

    require 'bundler/capistrano'
    require 'rvm/capistrano'
    
    set :rvm_ruby_string, "ruby-1.9.3-p125"
    set :rvm_type, 'webadmin'
    

    For more information you can visit this link rvm/capistrano

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

today I just ran rake db:migrate... well, two things happened, first it reversed from
I just ran heroku rake db:migrate and three of my most recent migrations are
Just updated albacore to version 0.14 and ran into a major problem. My current
I just ran a search for PHP.ini file in my C:\WAMP server and gosh!
I ran rake db:migrate to re-sync schema.db with my database schema. But it failed,
just ran gem update on a light use server machine that hadn't been updated
I just ran into this issue while making a GET request to a node.js
I just ran into a problem with the version of JAX-WS in JDK 1.6.0
I just ran across a question with an answer suggesting the AntiXss library to
I just ran across an issue that probably exposes my ignorance of common threading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.