Ruby on rails 使用git时出现Capistrano错误
我正在尝试设置capistrano,并希望在服务器上测试之前在本地测试我的配置,但是当我运行cap deploy-n时,会出现以下与git相关的错误Ruby on rails 使用git时出现Capistrano错误,ruby-on-rails,git,deployment,capistrano,Ruby On Rails,Git,Deployment,Capistrano,我正在尝试设置capistrano,并希望在服务器上测试之前在本地测试我的配置,但是当我运行cap deploy-n时,会出现以下与git相关的错误 /Users/josh/.rvm/gems/ruby-1.9.3-p448@wgbh/gems/capistrano-2.15.5/lib/capistrano/recipes/deploy/scm/git.rb:234:in `block in query_revision': undefined method `sub' for nil:Nil
/Users/josh/.rvm/gems/ruby-1.9.3-p448@wgbh/gems/capistrano-2.15.5/lib/capistrano/recipes/deploy/scm/git.rb:234:in `block in query_revision': undefined method `sub' for nil:NilClass (NoMethodError)
为此,我们将采取以下措施:
* 2013-08-26 12:12:30 executing `deploy'
* 2013-08-26 12:12:30 executing `deploy:update'
** transaction: start
* 2013-08-26 12:12:30 executing `deploy:update_code'
* executing locally: "git ls-remote git@github.com:GIT_REPO GIT_BRANCH"
*** [deploy:update_code] rolling back
* executing "rm -rf /u/apps/APP_NAME/releases/20130826161230; true"
require "bundler/capistrano"
set :application, "APP_NAME"
set :deply_to, "/the/server/path"
set :user, "SERVER_USER"
set :repository, "git@github.com:GIT_REPO_PATH"
set :scm, :git
set :scm_username , "GIT_USER_NAME"
#this allows you to choose a branch in the command line or default to master with 'cap -S branch=branchname deploy'
set :branch, fetch(:branch, "master")
#tells is to do resuse a single remote git clone
set :deploy_via, :remote_cache
server "THE_SERVER_NAME", :app, :web, :db, :primary => true
after 'deploy:update_code', 'deploy:migrate'
# If you are using Passenger mod_rails uncomment this:
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
我试着追溯这一点,但我似乎不知道是什么原因造成的。My deploy.rb如下所示:
* 2013-08-26 12:12:30 executing `deploy'
* 2013-08-26 12:12:30 executing `deploy:update'
** transaction: start
* 2013-08-26 12:12:30 executing `deploy:update_code'
* executing locally: "git ls-remote git@github.com:GIT_REPO GIT_BRANCH"
*** [deploy:update_code] rolling back
* executing "rm -rf /u/apps/APP_NAME/releases/20130826161230; true"
require "bundler/capistrano"
set :application, "APP_NAME"
set :deply_to, "/the/server/path"
set :user, "SERVER_USER"
set :repository, "git@github.com:GIT_REPO_PATH"
set :scm, :git
set :scm_username , "GIT_USER_NAME"
#this allows you to choose a branch in the command line or default to master with 'cap -S branch=branchname deploy'
set :branch, fetch(:branch, "master")
#tells is to do resuse a single remote git clone
set :deploy_via, :remote_cache
server "THE_SERVER_NAME", :app, :web, :db, :primary => true
after 'deploy:update_code', 'deploy:migrate'
# If you are using Passenger mod_rails uncomment this:
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
还有其他人经历过这个错误吗?我发现,但遵循一个建议根本不会改变错误。查看引用错误的来源:
command = scm('ls-remote', repository, revision)
result = yield(command)
revdata = result.split(/[\t\n]/)
newrev = nil
revdata.each_slice(2) do |refs|
rev, ref = *refs
if ref.sub(/refs\/.*?\//, '').strip == revision.to_s # Explosion!
...
end
似乎没有为所选分支或存储库加载修订数据(
ref
在调用sub
时为nil)。尝试自己运行指定的命令(git ls remote)git@github.com:GIT_REPO GIT_BRANCH
),希望生成更具体的错误消息,可能涉及分支或存储库本身。查看引用错误的来源:
command = scm('ls-remote', repository, revision)
result = yield(command)
revdata = result.split(/[\t\n]/)
newrev = nil
revdata.each_slice(2) do |refs|
rev, ref = *refs
if ref.sub(/refs\/.*?\//, '').strip == revision.to_s # Explosion!
...
end
似乎没有为所选分支或存储库加载修订数据(
ref
在调用sub
时为nil)。尝试自己运行指定的命令(git ls remote)git@github.com:GIT_REPO GIT_BRANCH
),可能会生成更具体的错误消息,可能涉及分支或存储库本身。问题似乎是,在干运行模式下,本地运行函数返回数组,不是预期的字符串
看
不确定git配方是否有一种简单的方法来确定它处于干运行模式。如果你只是侵入这样的东西:
# in recipes/deploy/scm/git.rb ~line 229
result = yield(command)
return "666" if result.class == Array # better would be: dry_run?
然后-n调用继续。问题似乎是,在干运行模式下,本地运行函数返回一个数组,而不是预期的字符串 看 不确定git配方是否有一种简单的方法来确定它处于干运行模式。如果你只是侵入这样的东西:
# in recipes/deploy/scm/git.rb ~line 229
result = yield(command)
return "666" if result.class == Array # better would be: dry_run?
然后-n调用继续。运行该命令返回0A6F2B064A09FF2963E9704040A81CEF976F94C5A refs/heads/development,因此它似乎获得了正确的修订信息运行该命令返回0A6F2B064A09FF2963E97040A81CEF976F94C5A refs/heads/development,因此它似乎获得了正确的修订信息capistrano中开始解决此问题的请求。capistrano中有一个pull请求开始解决这个问题。