Capistrano :: Configuration:Class的未定义方法`instance’

我试图让Capistrano第一次在rails应用程序中运行。 我有一个运行Ubuntu 12.04,nginx,unicorn和rails的linux服务器,但是,我似乎遇到了一些问题。 我也使用Capistrano 3.0.0,rails 3.2.14,bundler 1.4.0和ruby 1.9.3p448使用RVM。

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

当我尝试命令cap production deploy:checkcap production deploy:setup (似乎已弃用?)使用下面的设置,我得到以下错误消息:

我不确定从哪里开始这个错误,谷歌并没有多少建议。 我试过添加rvm-capistranogem,但无济于事。 如何修改代码以解决此错误?

  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 `' config/deploy.rb:1:in `' /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 ' /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 `' /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 `' 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' 

部署/ 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 } 

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

注意降级到capistrano 2.15.5,摆脱了错误。

首先,在capistrano 3中进行了一些更改。请参阅发行说明: http//www.capistranorb.com/2013/06/01/release-announcement.html

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

Capistrano 3已将捆绑器集成转移到gem.To解决您的问题:

  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. 

哦,如果您还不想使用捆绑包,请删除第一行:require“bundler / capistrano”。 很简单。

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

我会更容易回到capistrano v2。

我怀疑这个问题是因为Bundler 1.3.5与最新版本的Capistrano不兼容。 尝试升级到Bundler预发行版: gem install bundler --pre


我还注意到你使用的是非常旧版本的Rails 3.2,它可能容易受到一些安全漏洞的攻击。 我真的强烈建议将该版本的Rails升级到更新的版本,比如Rails 3.2.14。

对于Capistrano 3,他们建议使用http://github.com/capistrano/bundler

它在这里提到https://github.com/bundler/bundler/blob/master/lib/bundler/capistrano.rb