【问题标题】:RVM + Capistrano failed error bug?RVM + Capistrano 失败的错误错误?
【发布时间】:2013-02-15 07:52:43
【问题描述】:

我目前正在部署我的应用程序,由于某些奇怪的原因,我在执行 cap:deploy 时不断收到此错误。我已经在互联网上尝试了所有方法,但找不到解决此问题的方法

*** [deploy:update_code] rolling back
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'default' -c 'git clone -q --depth 1 git@github.com:username/appname.git /var/www/site/app/releases/20130215074544 && cd /var/www/site/app/releases/20130215074544 && git checkout -q -b deploy ab30e0f75c1876026a6c658094170e73 && (echo ab30e0f75c1876026a6c658094170e73 > /var/www/site/app/releases/20130215074544/REVISION)'" on xxx.xxx.xx.xxx

我不确定这意味着什么,并且已经尝试了从 stackoverflow 问题到谷歌的所有建议,但没有任何效果。

我什至在我的部署文件中尝试过这个,但没有任何效果

require "rvm/capistrano"
set :rvm_ruby_string, 'default'
set :rvm_type, :system

宝石文件

group :development, :test do
  gem "capistrano", "~> 2.14.2"
  gem 'rvm-capistrano', '~> 1.3.0.rc9'
end

部署.rb

set :rvm_ruby_string, :local        # use the same ruby as used locally for deployment

before 'deploy', 'rvm:install_rvm'  # update RVM
before 'deploy', 'rvm:install_ruby' # install Ruby and create gemset (both if missing)

require "rvm/capistrano"

    set :application, "appname"
    set :repository, "git@github.com:username/appname.git"

    set :scm, 'git'

    role :web, "xxx.xxx.xx.xxx" # Your HTTP server, Apache/etc
    role :app, "xxx.xxx.xx.xxx" # This may be the same as your `Web` server
    role :db, "xxx.xxx.xx.xxx", :primary => true # This is where Rails migrations will run

    set :user, 'usernameyousetupforserver'
    set :branch, "master"
    set :rvm_type, :user

    set :git_shallow_clone, 1
    set :use_sudo, false
    set :deploy_to, "/path/public/#{application}"
    set :deloy_via, :remote_cache
    set :keep_releases, 1
    set :rails_env, "production"
    set :migrate_target, :latest

    default_run_options[:pty] = true
    ssh_options[:forward_agent] = true



     namespace :deploy do
       task :start do ; end
       task :stop do ; end
       task :restart, :roles => :app, :except => { :no_release => true } do
         run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
       end
     end

     namespace :deploy do
       desc "Recreate symlink"
       task :resymlink, :roles => :app do
         run "rm -f #{current_path} && ln -s #{release_path} #{current_path}"
       end
     end

开发日志

    * 2013-02-16 12:39:55 executing `deploy'
* 2013-02-16 12:39:55 executing `deploy:update'
* transaction: start
* 2013-02-16 12:39:55 executing `deploy:update_code'
  executing locally: "git ls-remote git@github.com:username/appname.git master"
  command finished in 1310ms
* executing "git clone -q --depth 1 git@github.com:username/appname.git /var/www/site/app/releases/20130216183956 && cd /var/www/site/app/releases/20130216183956 && git checkout -q -b deploy ab30e0f75c1876026a6c658094170e73 && (echo ab30e0f75c1876026a6c658094170e73 > /var/www/site/app/releases/20130216183956/REVISION)"
  servers: ["xxx.xxx.xx.xxx"]
ssword: 
  [xxx.xxx.xx.xxx] executing command
  command finished in 22960ms
* 2013-02-16 12:40:24 executing `deploy:finalize_update'
  triggering before callbacks for `deploy:finalize_update'
* 2013-02-16 12:40:24 executing `deploy:assets:symlink'
* executing "rm -rf /var/www/site/app/releases/20130216183956/public/assets &&\\\n        mkdir -p /var/www/site/app/releases/20130216183956/public &&\\\n        mkdir -p /var/www/site/app/shared/assets &&\\\n        ln -s /var/www/site/app/shared/assets /var/www/site/app/releases/20130216183956/public/assets"
  servers: ["xxx.xxx.xx.xxx"]
  [xxx.xxx.xx.xxx] executing command
  command finished in 716ms
* executing "chmod -R -- g+w /var/www/site/app/releases/20130216183956 && rm -rf -- /var/www/site/app/releases/20130216183956/public/system && mkdir -p -- /var/www/site/app/releases/20130216183956/public/ && ln -s -- /var/www/site/app/shared/system /var/www/site/app/releases/20130216183956/public/system && rm -rf -- /var/www/site/app/releases/20130216183956/log && ln -s -- /var/www/site/app/shared/log /var/www/site/app/releases/20130216183956/log && rm -rf -- /var/www/site/app/releases/20130216183956/tmp/pids && mkdir -p -- /var/www/site/app/releases/20130216183956/tmp/ && ln -s -- /var/www/site/app/shared/pids /var/www/site/app/releases/20130216183956/tmp/pids"
  servers: ["xxx.xxx.xx.xxx"]
  [xxx.xxx.xx.xxx] executing command
  command finished in 521ms
  triggering after callbacks for `deploy:update_code'
* 2013-02-16 12:40:25 executing `deploy:assets:precompile'
* executing "cd /var/www/site/app/releases/20130216183956 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
  servers: ["xxx.xxx.xx.xxx"]
  [xxx.xxx.xx.xxx] executing command
* [out :: xxx.xxx.xx.xxx] Could not find aws-sdk-1.8.2 in any of the sources
* [out :: xxx.xxx.xx.xxx] Run `bundle install` to install missing gems.
  command finished in 1132ms
* [deploy:update_code] rolling back
* executing "rm -rf /var/www/site/app/releases/20130216183956; true"
  servers: ["xxx.xxx.xx.xxx"]
  [xxx.xxx.xx.xxx] executing command
  command finished in 508ms
Failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ruby-1.9.3-p385' -c 'cd /var/www/site/app/releases/20130216183956 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on xxx.xxx.xx.xxx

是什么导致了这个错误,我可以做些什么来解决它?

【问题讨论】:

  • 您是否尝试过在远程服务器上运行失败的命令?也许你看到它失败了
  • 部署用户(即“usernameyousetupforserver”)是否能够从部署应用程序的位置访问您的 git 存储库? cap deploy:check 的输出是什么?
  • @ViktorTrón 在服务器上运行失败的命令时,我得到了Permission denied (publickey). fatal: The remote end hung up unexpectedly

标签: ruby-on-rails ruby deployment capistrano rvm-capistrano


【解决方案1】:

您似乎错过了阅读文档https://github.com/wayneeseguin/rvm-capistrano#readme

此处描述了新版本 1.3.0.rc11:https://github.com/wayneeseguin/rvm-capistrano/blob/feature/readme_for_1.3.0/README.md

我看到脚本中没有捆绑器集成:

require "rvm/capistrano"
require "bundler/capistrano"
load 'deploy/assets'

这是我的部署脚本,例如应用程序https://github.com/mpapis/ad/blob/master/config/deploy.rb

【讨论】:

  • 阅读文档并用新代码替换旧代码后,我仍然面临同样的错误失败:“rvm_path=$HOME/.rvm/$HOME/.rvm/bin/rvm-shell 'ruby-1.9.3-p385' -c 'cd --。我过去部署没有问题,但现在有很多问题。这是 capistrano 或 capistrano/rvm 的错误吗?
  • 确保显示整个输出,这是调试 capistrano 错误所必需的 - 也请将代码更新到新版本
  • 在查看了您的部署文件后,我更改了一些内容,并且成功了。谢谢!!
  • @coletrain “你改变了一些东西”是什么意思?
  • @noz 我最终使用了set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,""),并将上面答案中的代码放在了我的 deploy.rb 文件的底部
【解决方案2】:

转到您的github settings ssh section 并将远程服务器用户的 ssh 公钥添加到您的密钥中。这个密钥在 Linux 上的 /home/username/.ssh/id_rsa.pub 下。

【讨论】:

  • 这有助于从服务器运行 fail 命令,但在通过 rvm/capistrano 部署到服务器时仍然无法解决问题。
猜你喜欢
  • 1970-01-01
  • 2015-12-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-17
相关资源
最近更新 更多