ruby-on-rails-3 - sh : rake: not found on freshly installed server

标签 ruby-on-rails-3 deployment capistrano

我在第一次部署代码时遇到错误。我多次使用相同的脚本,并且成功运行。

我在部署时遇到的错误:

 [out :: ***********] sh: rake: not found

我正在使用 RVM,Ruby 1.9.2

部署脚本输出:

  executing `deploy:after_symlink'
  * executing "cp /home/me/my_app/shared/database.yml /home/me/my_app/current/config/database.yml"
    servers: ["**************"]
    ["**************"] executing command
    command finished in 1204ms
  * executing `deploy:migrate'
  * executing "cd /home/me/my_app/current && rake db:migrate RAILS_ENV=production"
    servers: ["**************"]
   ["**************"] executing command
 ** [out :: ***********] sh: rake: not found  // Here is the issue
    command finished in 1023ms
*** [deploy:symlink] rolling back
  * executing "ls -x /home/me/my_app/releases"

gem 列表:在服务器上

gem list

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.1.0, 3.0.10)
actionpack (3.1.0, 3.0.10)
activemodel (3.1.0, 3.0.10)
activerecord (3.1.0, 3.0.10)
activeresource (3.1.0, 3.0.10)
activesupport (3.1.0, 3.0.10)
arel (2.2.1, 2.0.10)
bcrypt-ruby (3.0.1)
builder (3.0.0, 2.1.2)
bundler (1.0.21)
daemon_controller (0.2.6)
erubis (2.7.0, 2.6.6)
fastthread (1.0.7)
hike (1.2.1)
i18n (0.6.0, 0.5.0)
mail (2.3.0, 2.2.19)
mime-types (1.16)
multi_json (1.0.3)
mysql2 (0.2.7)
passenger (3.0.9)
polyglot (0.3.2)
rack (1.3.4, 1.2.4)
rack-cache (1.0.3)
rack-mount (0.8.3, 0.6.14)
rack-ssl (1.3.2)
rack-test (0.6.1, 0.5.7)
rails (3.0.10)
railties (3.1.0, 3.0.10)
rake (0.9.2)
rdoc (3.9.4)
sprockets (2.0.2)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.30)

我用来部署的脚本:

set :stages, %w(production staging)
require 'capistrano/ext/multistage'

server "Server IP", :app, :web, :db, :primary => true

set(:application) { "app_name" }
set (:deploy_to) { "/home/binarymesh/#{application}" }
set :user, 'my_user'
set :keep_releases, 3
set :repository, "git@github.com:MyRepo"
set :use_sudo, false
set :scm, :git
default_run_options[:pty] = true
ssh_options[:forward_agent] = false
set :deploy_via, :remote_cache
set :git_shallow_clone, 1
set :git_enable_submodules, 1

namespace :deploy do
 desc "Restarting mod_rails with restart.txt"
 task :restart, :roles => :app, :except => { :no_release => true } do
   run "touch #{current_path}/tmp/restart.txt"
 end

 [:start, :stop].each do |t|
   desc "#{t} task is a no-op with mod_rails"
   task t, :roles => :app do ; end
 end

 desc "invoke the db migration"
 task:migrate, :roles => :app do
   send(run_method, "cd #{current_path} && rake db:migrate RAILS_ENV=#{stage} ")
 end


 desc "Deploy with migrations"
  task :long do
    transaction do
      update_code
      web.disable
      symlink
      migrate
    end

    restart
    web.enable
    cleanup
  end

 task :after_symlink, :roles => :app do
   run "cp #{shared_path}/database.yml #{current_path}/config/database.yml"
 end

  desc "Run cleanup after long_deploy"
  task :after_deploy do
    cleanup
  end

end

最佳答案

require "rvm/capistrano"

在我的情况下,在 deploy.rb 之上就足够了。

关于ruby-on-rails-3 - sh : rake: not found on freshly installed server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7679178/

相关文章:

ruby-on-rails - 如何获取 Formtastic 日期/时间选择的默认值?

php - 在生产中升级到 Drupal

ruby-on-rails - 如何将 Capistrano 与 Apache 或 Nginx 一起使用?

capistrano - 如何在 capistrano 任务中添加一些步骤?

ruby-on-rails-3 - 为 json View 编写测试用例的最佳方式? (即网络服务)

ruby-on-rails-3 - 如何销毁resque worker 排队的工作?

node.js - 如果 webpack 构建失败则中止 post-receive Hook

ruby-on-rails - Bundler 似乎无法通过 Rbenv 找到正确的 Ruby

ruby-on-rails - Capistrano throw 装置 secret_key 未设置

ruby-on-rails - 将种子数据添加到开发数据库进行测试