这是我第一次在DigitalOcean中部署rails应用程序,但我在部署应用程序时遇到了问题。当我尝试运行cap production deploy
或bundle 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'
答案 0 :(得分:1)
您正在尝试使用与您的Capistrano版本不兼容的不同Capistrano扩展程序。您的Capistrano版本是2.x(按Capfile的格式检测),但capistrano/bundler
例如是Capistrano 3.x的扩展名。
只需使用Capistrano 3(如果可能)和兼容的扩展程序。