部署 Ubuntu Capistrano 部署问题:bundle:command not found

cderong · 2013年07月02日 · 最后由 cderong 回复于 2013年07月03日 · 7129 次阅读

主机:Ubuntu Server 12.04 LTS(我的 CentOS 主机没遇到这个问题)

Capistrano 报错,如图:

Cap 远程执行'echo $PATH',说明 ssh remote PATH 中没有 bundle 的路径,故报错

但,ssh 登录主机,执行'echo $PATH',PATH 中是有 bundle 路径的,如图:

请教:如何让 ssh remote 也有 bundle 路径?谢谢。

rvm 问题吧,

试试 rvm-capistrano 吧

#1 楼 @kevinxu CenOS 完全正常,不是 rvm 问题吧?

没跑能触发 rvm 的初始化脚本吧。。。

#3 楼 @iBachue 哪个 rvm 初始化脚本?source /usr/local/rvm/scripts/rvm?ssh登录rvm,bundle路径在PATH中是有的。

#4 楼 @cderong 是啊 你可以尝试在跑这个脚本前插入句什么命令以检测是否确实跑到了这个脚本。

把 deploy.rb 贴出来看看~

粗体的几行加上就好了。 deploy.rb:

coding: utf-8

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

set :application, "aaa" set :repository, "https://aaa:[email protected]:8443/git/web.git" set :branch, "single" set :scm, :git set :user, "deployer" set :deploy_to, "/home/#{user}/#{application}" #set :deploy_via, :remote_cache set :use_sudo, false

** default_run_options[:pty] = true ** ** set :rvm_ruby_string, 'ruby-1.9.3-p448@global' ** ** set :rvm_type, :system **

role :web, "192.168.5.100" role :app, "192.168.5.100" role :db, "192.168.5.100", :primary => true

unicorn.rb 路径

set :unicorn_path, "#{deploy_to}/current/config/unicorn.rb" set :unicorn_pid, "#{deploy_to}/current/tmp/pids/unicorn.pid"

namespace :deploy do task :start, :roles => :app do run "cd #{deploy_to}/current/; bundle exec unicorn_rails -c #{unicorn_path} -E production -D" end

task :stop, :roles => :app do run "kill -QUIT cat #{deploy_to}/current/tmp/pids/unicorn.pid" end

desc "Restart Application" task :restart, :roles => :app do run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -QUIT cat #{unicorn_pid}; fi" run "cd #{deploy_to}/current && bundle exec unicorn_rails -c #{unicorn_path} -E production -D" end

task :assets, :roles => :app do run "cd #{deploy_to}/current; RAILS_ENV=production bundle exec rake assets:precompile" end end

task :init_shared_path, :roles => :web do run "mkdir -p #{deploy_to}/shared/report" end

task :link_shared_files, :roles => :web do run "ln -sf #{deploy_to}/shared/report #{deploy_to}/current/public/" end

after 'deploy:update', 'deploy:migrate' after 'deploy:update', 'deploy:assets'

需要 登录 后方可回复, 如果你还没有账号请 注册新账号