Capistrano :: Configuration:Class的未定义方法`实例' [英] Undefined method `instance' for Capistrano::Configuration:Class

查看:91
本文介绍了Capistrano :: Configuration:Class的未定义方法`实例'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Capistrano第一次在Rails应用中运行起来。我有一台运行Ubuntu 12.04的Linux服务器,nginx,unicorn和rails,但是,我似乎遇到了一些问题。我也使用Capistrano 3.0.0,rails 3.2.14,bundler 1.4.0&红宝石1.9.3p448使用RVM。



我只设置了一个制作阶段,此时我只关心Capistrano与我的服务器进行通信,并从github推送我的代码(没有迁移并绑定等等。)



当我尝试命令 cap production deploy:check cap production deploy:setup (似乎不推荐使用),但是出现以下错误消息:



I我不确定从哪里开始出现这个错误,而谷歌并没有太多建议。我尝试添加 rvm-capistrano gem但无济于事。如何修改我的代码来解决这个错误?

  cap aborted! 
Capistrano :: Configuration的未定义方法`instance':
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.4.0.rc.1/ lib / bundler / capistrano.rb:11:在< top(required)>'
config / deploy.rb:1:在< top(required)>'
/ Users /andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/setup.rb:12:in`load'
/Users/andrew/.rvm/ gems / ruby​​-1.9.3-p448 / gems / capistrano-3.0.0 / lib / capistrano / setup.rb:12:在< top(required)>中的block(2 levels)'
/ Users / andrew / .rvm / gems / ruby​​-1.9.3-p448 / gems / capistrano-3.0.0 / lib / capistrano / application.rb:12:在'run'
/Users/andrew/.rvm /gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/bin/cap:3:in`< top(required)>'
/Users/andrew/.rvm/gems/ ruby-1.9.3-p448 / bin / cap:23:in`load'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/bin/cap:23:in`<主要>'
任务:TOP =>生产
(通过使用-trace运行任务来查看完整跟踪)

deploy.rb

  requirebundler / capistrano

set:舞台,%w(舞台制作)
set:default_stage,production

set:application,my_app
set:user,andrew
set:scm,git
set :repository,https://github.com/my_repo/#{application}
set:branch,master

set:deploy_to,/ home / rails /#{应用程序}
set:deploy_via,:remote_cache
set:use_sudo,false

default_run_options [:pty] = true
ssh_options [:forward_agent] = true $ b deploy,deploy:cleanup后的
$ b#仅保留最后5个版本

命名空间:deploy do
任务:重新启动,角色:: app do
运行touch#{current_path} tmp / restart.txt
end
end
完成后,'deploy:cleanup'

deploy / production.rb

 #已完成IP省略
服务器10.2.32.68,:web,:app,:db,primary:true

/ p>

 #加载DSL和设置上升阶段
需要'capistrano / setup'

#包括默认部署任务
需要'capistrano / deploy'

#require'capistrano / rvm'
#require'capistrano / rbenv'
#require'capistrano / chruby'
#require'capistrano / bundler'
#require'capistrano / rails / assets'
#require'capistrano / rails / migrations'

#将自定义任务从`lib / capistrano / tasks'如果你有任何定义。
Dir.glob('lib / capistrano / tasks / *。cap')。each {| r | import r}

编辑查看capistrano.rb中的违规行在bundler中,它提到将require'bundler / deployment'添加到deploy.rb中,似乎它已经摆脱了capistrano实例错误。


$ b

强>降级到capistrano 2.15.5,它消除了错误。

首先,有一些变化made in capistrano 3.
请参阅发行说明: http://www.capistranorb.com/2013/06/01/release-announcement.html



另请阅读自述文件。
https://github.com/capistrano/capistrano/ blob / master / README.md



Capistrano 3已经将捆绑器集成到一个gem中。解决您的问题:

  1.取消注释要求capistrano / bundler'capify。 
2.将gem'capistrano-bundler'添加到您的gem文件中。
3.阅读capify文件中的注释并取消注释您需要的模块。

如果您还不想使用捆绑器,请删除第一行:需要bundler / capistrano。就像那样简单。



现在你也不能像以前那样使用变量。而是直接读取它,而不是使用fetch(:application)来读取一个变量。



我会更容易回到capistrano v2。


I am trying to get Capistrano up and running for the first time in a rails app. I have a linux server running Ubuntu 12.04, nginx, unicorn and rails, however, I seem to be running into a few issues. I am also using Capistrano 3.0.0, rails 3.2.14, bundler 1.4.0 & ruby 1.9.3p448 using RVM.

I only have a production stage set up and at this point in time and I'm only concerned with Capistrano communicating with my server and pushing my code from github ( No migrations and bundling etc just yet).

When I try the command cap production deploy:check or cap production deploy:setup ( which seems to be deprecated?) with the setup below, I get the following error msg:

I'm not really sure where to start on this error, and google doesn't suggest much. I have tried adding the rvm-capistrano gem but to no avail. How can I amend my code to address this error?

    cap aborted!
undefined method `instance' for Capistrano::Configuration:Class
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.4.0.rc.1/lib/bundler/capistrano.rb:11:in `<top (required)>'
config/deploy.rb:1:in `<top (required)>'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/setup.rb:12:in `load'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/setup.rb:12:in `block (2 levels) in <top (required)>'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/application.rb:12:in `run'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/bin/cap:3:in `<top (required)>'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/bin/cap:23:in `load'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/bin/cap:23:in `<main>'
Tasks: TOP => production
(See full trace by running task with --trace)

deploy.rb

require "bundler/capistrano"

set :stages, %w(staging production)
set :default_stage, "production"

set :application, "my_app"
set :user, "andrew"
set :scm, "git"
set :repository, "https://github.com/my_repo/#{application}"
set :branch, "master"

set :deploy_to, "/home/rails/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false

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

after "deploy", "deploy:cleanup" # keep only the last 5 releases

namespace :deploy do
  task :restart, roles: :app do
      run "touch #{current_path}tmp/restart.txt"
    end
  end
  after :finishing, 'deploy:cleanup'

deploy/production.rb

#Real IP ommitted 
server "10.2.32.68", :web, :app, :db, primary: true

Capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
# require 'capistrano/bundler'
# require 'capistrano/rails/assets'
# require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

EDIT After looking at the offending line in capistrano.rb within bundler it mentions to add require 'bundler/deployment' to deploy.rb, which has seemed to get rid of the capistrano instance error.

NOTE Downgraded to capistrano 2.15.5 which got rid of the errors.

解决方案

First of all, there were a couple of changes made in capistrano 3. See the release notes : http://www.capistranorb.com/2013/06/01/release-announcement.html

Also go through the readme. https://github.com/capistrano/capistrano/blob/master/README.md

Capistrano 3 has moved out bundler integration into a gem.To solve your problem :

 1. Uncomment require 'capistrano/bundler' from capify. 
 2. add gem 'capistrano-bundler' to your gemfile.
 3. Go through the comments in capify file and uncomment whichever module you require.

Oh and if you don't wanna use bundler as of yet, remove the first line : require "bundler/capistrano". easy as that.

Also you can't use variables like the previous way now.Instead of directly reading it, use fetch(:application) to read a variable.

I would be easier for you to move back to capistrano v2.

这篇关于Capistrano :: Configuration:Class的未定义方法`实例'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆