Rails应用程序gem中“desc”关键字的问题

时间:2013-06-26 14:59:22

标签: ruby-on-rails gem capistrano

我正在尝试在我正在使用的Ruby Rails应用程序中安装一个新的gem。 (Dotenv,为那些感兴趣的人解释here。)但是,每次我尝试将其包含在应用程序中时,我的部署都会崩溃并出现以下错误:

/Users/nadams/.rvm/gems/ruby-2.0.0-p0@orbit/gems/dotenv-0.8.0/lib/dotenv/tasks.rb:1:
    in `<top (required)>: undefined method `desc' for main:Object (NoMethodError)

QUESTION PROPER:“desc”关键字来自哪里?

(我认为问题是capistrano添加了“desc”方法,并且出于某种原因,在Capistrano之前加载Dotenv。但是我对此不太了解。)

这是我的部署文件:

require "bundler/capistrano"
require "capistrano/ext/multistage"
require "rvm/capistrano"

load "config/recipes/base"
load "config/recipes/nginx"
load "config/recipes/unicorn"
load "config/recipes/git"
load "config/recipes/mysql"
load "config/recipes/shared"
load "config/recipes/check"

# Sets up dotenv...
require "dotenv"
require "dotenv/tasks"
require "dotenv/capistrano"
Dotenv.load
# ...done

set :application, "orbit-server"
set :user, "deploy"
set :bundle_cmd, "/usr/local/rvm/gems/ruby-2.0.0-p0@global/bin/bundle"
set :default_stage, "testing"
set :deploy_to, "/home/deploy/rails_apps/orbit-server"
set :deploy_via, :remote_cache
set :rvm_ruby_string, "ruby-2.0.0-p0@orbit"
set :rvm_type, :system
set :stages, %w( production staging testing )
set :use_sudo, false

# TODO Remove this code when I get Dotenv working
puts "Deploy branch: "+(ENV["DEPLOY_BRANCH"].nil? ? "nil" :ENV["DEPLOY_BRANCH"])
ENV["DEPLOY_BRANCH"]="release-notes"

set :scm, "git"
set :repository, "git@github.com:[my/repo].git"
set :branch, ENV["DEPLOY_BRANCH"].nil? ? "master" : ENV["DEPLOY_BRANCH"]

default_run_options[:pty] = true
ssh_options[:forward_agent] = true

after "deploy", "deploy:cleanup"

感谢您的帮助!

1 个答案:

答案 0 :(得分:3)

desc是一种rake方法。您可以require 'rake'或删除:

删除:

require "dotenv/tasks"

似乎没有任何理由这样做。