Capistrano ( Rails ) 中未定义的方法“命名空间”

Undefined method `namespace' in Capistrano ( Rails )

这是我第一次在 DigitalOcean 中部署 rails 应用程序,但我在部署应用程序时遇到了问题。当我尝试 运行 cap production deploybundle exec cap deploy:setup 我得到一个错误:

/usr/local/rvm/gems/ruby-2.2.0/gems/capistrano-bundler-1.1.4/lib/capistrano/tasks/bundler.cap:1:in `<top (required)>': undefined method `namespace' for main:Object (NoMethodError)

这是我的deploy.rb

set :application, "myapp.com"
set :repository,  "git@heroku.com:myapp.git"

set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :user, 'user'
set :use_sudo, false
set :deploy_to, "/home/user/video-benta"
set :deploy_via, :remote_cache

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

# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
after "deploy", "deploy:bundle_gems"
after "deploy:bundle_gems", "deploy:restart"

 namespace :deploy do
   task :bundle_gems do
        run "cd #{deploy_to}/current && bundle install vendor/gems"
   end
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "touch #{File.join(current_path,'tmp','restart.txt')}"
   end
 end

Capfile(更新)

load 'deploy'
# Uncomment if you are using Rails' asset pipeline
    # load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
require 'capistrano/bundler'
require 'capistrano/rails'

# If you are using rvm add these lines:
require 'capistrano/rvm'
 set :rvm_type, :user
 set :rvm_ruby_version, '2.2.0p0'

您正在尝试使用与您的 Capistrano 版本不兼容的不同 Capistrano 扩展。您的 Capistrano 版本是 2.x(由您的 Capfile 格式检测),但是 capistrano/bundler 例如是 Capistrano 3.x 的扩展。

只需使用 Capistrano 3(如果可能)和兼容的扩展。