【问题标题】:Undefined method `namespace' in Capistrano ( Rails )Capistrano(Rails)中未定义的方法“命名空间”
【发布时间】:2015-02-28 08:41:21
【问题描述】:

这是我第一次在 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'

【问题讨论】:

  • 能否请您提供您的Capfile(在应用程序目录的根目录中)?
  • 您好,先生,我更新了我的问题。谢谢!

标签: ruby-on-rails ruby capistrano digital-ocean


【解决方案1】:

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

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

【讨论】:

  • gem 'capistrano', '~> 3.1.0' gem 'capistrano-bundler', '~> 1.1.2' gem 'capistrano-rails', '~> 1.1.1' gem ' capistrano-rvm', github: "capistrano/rvm -- 那是我的 capistrano gems .. 我不知道当我尝试这个 cap install STAGES=production 时它不起作用。因为它不起作用我尝试的第一个Capify .
  • Capify 是来自 Capistrano 2.x 的二进制文件。好像它之前已经安装在您的系统中,然后您运行它并以旧格式生成 Capfile。阅读 Capistrano 3.x 的 section about installation
  • 我已经为 Capistrano 更改了新版本,但是当我运行 cap production deploy 时出现错误 Error writing to authentication socket. DEBUG [1da99c71] Permission denied (publickey). DEBUG [1da99c71] fatal: Could not read from remote repository. DEBUG [1da99c71] DEBUG [1da99c71] Please make sure you have the correct access rights DEBUG [1da99c71] and the repository exists. 我已经在 heroku 中添加了一个 ssh 密钥。
  • 这是另一种问题。尝试在此处创建新问题帖子。
  • stackoverflow.com/questions/28781134/… - 这是我的新线程@maxd .. 顺便谢谢你。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-05-17
  • 2020-03-30
  • 1970-01-01
  • 2019-10-21
  • 2011-07-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多