sh: rake: 在新安装的服务器上找不到
我在第一次部署代码时遇到错误。我多次使用同一个脚本,而且效果很成功。
部署时遇到错误:
[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 List:在服务器上
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, "[email protected]: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
I am getting an error while deploying code for the first time. I used the same script so many times, and it worked successfully.
Error I am getting while deployment:
[out :: ***********] sh: rake: not found
I am using RVM, Ruby 1.9.2
Deploy script output:
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 List: on server
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)
Script i am using to deploy:
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, "[email protected]: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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我的例子中,在deploy.rb之上就足够了。
on top of deploy.rb was enough in my case.
将其添加
到我的deploy.rb 文件顶部解决了我的问题。
Adding this
on top my deploy.rb file solved my problem.