我试图在一个rails应用程序中首次获得Capistrano的运行.我有一个
linux服务器运行Ubuntu 12.04,Nginx,独角兽和rails,但是,我似乎正在遇到一些问题.我也使用Capistrano 3.0.0,rails 3.2.14,bundler 1.4.0&红宝石1.9.3p448使用RVM.
我只有一个生产阶段设置,在这个时间点,我只关心Capistrano与我的服务器通信,并推送我的代码从github(没有迁移和捆绑等).
当我尝试命令帽生产部署:检查或cap生产部署:安装程序(似乎已被弃用?)与下面的设置,我得到以下错误msg:
我不太确定从哪里开始出现这个错误,而谷歌并不建议太多.我已经尝试添加rvm-capistrano宝石,但没有用.如何修改我的代码来解决这个错误?
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'
部署/ 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 }
编辑在对捆绑机中capistrano.rb的违规行进行查看后,它提到要对deploy.rb添加require’bundler / deployment’,这似乎摆脱了capistrano实例的错误.
注意降级到capistrano 2.15.5,摆脱了错误.
解决方法
首先,capistrano 3有几个变化.
见发行说明: http://www.capistranorb.com/2013/06/01/release-announcement.html
见发行说明: http://www.capistranorb.com/2013/06/01/release-announcement.html
也请阅读自述文件.
https://github.com/capistrano/capistrano/blob/master/README.md
Capistrano 3已经将捆绑程序集成移植到gem中.解决您的问题:
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.
哦,如果你不想使用bundler,请删除第一行:require“bundler / capistrano”.容易如此
此外,您现在不能像以前的方式那样使用变量.不要直接读取它,请使用fetch(:application)来读取变量.
我会更容易回到capistrano v2.