为什么Capistrano从/ usr / bin / env而不是/usr/local/rvm/gems/ruby-2.1.0/bin/rake执行'rake'?

道格拉斯

当我执行cap生产部署Capistrano的任务时,它尝试从/ usr / bin / env执行rake,但是我的gem已安装到/usr/local/rvm/gems/ruby-2.1.0/bin/rake中!

版本: Ruby 2.1 / Capistrano 3.0.1 / Rake 10.1.1 / Rails 3.2.16 / rvm 1.25.12

我在myserver上使用rvm来方便进行ruby安装,但是我使用rvm_admin用户手动安装和审核了gems。rvm已“系统范围”安装。我不使用capistrano-rvm,也不使用capistrano-rails,因为我手动更新了ruby,gem,资产和迁移。

平台:正在将XUbuntu 12.04.4 LTS部署到Debian Wheezy

档案:

头文件

require 'capistrano/setup'
require 'capistrano/deploy'
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
deploy.rb
set :application, 'odpf'
set :repo_url, '[email protected]:myrepo/myapp.git'
set :branch, 'production_1.01'
set :deploy_to, '/var/www/odpf'
set :pty, false
set :scm, :git
set :format, :pretty


namespace :deploy do
  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      # l'exemple correspond à ce qu'il faut pour restart passenger :
      # http://www.modrails.com/documentation/Users%20guide%20Apache.html#_redeploying_restarting_the_ruby_on_rails_application
      execute :mkdir, '-p', "#{release_path}/tmp"
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end


  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # Conformément à : http://guides.rubyonrails.org/v3.2.14/command_line.html#tmp
      within release_path do
        execute :rake, 'tmp:cache:clear'
      end
    end
  end

  # Create symlink to database.yml after publication
  before 'deploy:published', 'db_access:create_symlinks'

  after :finishing, 'deploy:cleanup'
end

阶段文件(production.rb,staging.rb)

set :stage, :production
server 'myserver.net', user: 'rvm_admin', roles: %w{web app db}
set :ssh_options, { forward_agent: true, port: 8888 }

当我执行时cap production deploy,它会很好地执行到输出末尾的soem点为止:

INFO [0a0dbcb0] Running /usr/bin/env rake tmp:cache:clear on myserver.net
DEBUG [0a0dbcb0] Command: cd /var/www/odpf/releases/20140129101515 && /usr/bin/env rake tmp:cache:clear
DEBUG [0a0dbcb0] /usr/bin/env: rake
DEBUG [0a0dbcb0] : Aucun fichier ou dossier de ce type
cap aborted!
rake stdout: Nothing written
rake stderr: Nothing written
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/sshkit-1.0.0/lib/sshkit/command.rb:94:in `exit_status='
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'

Capistrano尝试执行耙,/usr/bin/env但我的gem安装在这里:

rvm_admin@myserver:/var/www/odpf/current$ bundle show rake
/usr/local/rvm/gems/ruby-2.1.0/gems/rake-10.1.1
rvm_admin@myserver:/var/www/odpf/current$ which rake
/usr/local/rvm/gems/ruby-2.1.0/bin/rake

我究竟做错了什么 ?

约书亚·帕林

可以肯定的是您没有做错任何事情,这是一个capistrano问题-rake没有执行该问题bundle exec在此处查看问题:https : //github.com/capistrano/capistrano/issues/639

该线程末尾还有一个建议的解决方案-

SSHKit.config.command_map[:rake] = "bundle exec rake"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么#!/ usr / bin / env将“ $ @”显示为1?

为什么#!/ usr / bin / env bash优于#!/ bin / bash?

为什么“#!/ usr / bin / env python”比“#!/ usr / bin / python”更正确?

/ usr / bin / env和Capistrano 3在Rails部署中失败

“#!/ usr / bin / env bash”和“#!/ usr / bin / bash”之间有什么区别?

python shebang与/ usr / bin / env而不是hard-path有什么区别?

在shebang中使用“#!/ usr / bin / env python”而不是仅仅调用“#!python”解释器有什么好处?

什么是/ usr / bin / parity?

什么是/ usr / local / bin?

heroku运行rake db:migrate错误“ / usr / bin / env:ruby2.2:没有这样的文件或目录”

在Java中执行/ usr / bin / env bash -c“ command”

什么是#!/ usr / bin / env xdg-open在桌面文件中?

/ usr / bin / env -0(对于非Linux系统)

symlink / usr / bin / env损坏?

从/ usr / bin / env或/ bin启动bash

为什么logrotate的bin路径是`/ usr / sbin`

为什么#!/ usr / bin / env bash在我的系统上不起作用?

为什么“ / usr / bin / env bash -x”仅在命令行中有效?

在这种情况下,为什么我可以将参数传递给/ usr / bin / env?

为什么最好使用“#!/ usr / bin / env名称”代替“#!/ path / to / NAME”作为我的shebang?

Python / usr / bin / env:错误的解释器:不是目录

无法在“ / usr / bin / java / bin / java”(-1)中找到可执行文件

/ usr / bin / pass和/ usr / bin / pass2

Cronjob执行`/ usr / bin / python`而不执行`usr / bin / xrdb`

为什么/ bin是指向/ usr / bin的符号链接?

POSIX shell脚本shebang#!/ bin / sh与#!/ usr / bin / env sh,有什么区别?

为什么“ / usr / bin /”和“ / usr / bin / X11 /”中的“相同”可执行文件?他们真的一样吗?

为什么在优胜美地的Xcode 6中出现错误“命令/ usr / bin / codesign失败,退出代码1”的错误?

为什么安装到/ usr / bin会自动安装到/ usr / bin / X11?