0

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

/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)

问题正确:“desc”关键字来自哪里?

(我认为问题在于 capistrano 添加了“desc”方法,并且由于某种原因,Dotenv 在 Capistrano 之前被加载。但我对此知之甚少,无法确定。)

这是我的部署文件:

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"

谢谢你的帮助!

4

1 回答 1

3

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

消除:

require "dotenv/tasks"

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

于 2013-06-26T15:39:32.690 回答