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



我正试图在我的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"关键字从哪里来?

(我认为问题是"desc"方法是由capistrano添加的,出于某种原因,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"

谢谢你的帮助!

desc是一个rake方法。您可以选择require 'rake',也可以删除:

删除:

require "dotenv/tasks"

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

最新更新