【问题标题】:Rails app fails to load as soon as i installed capistrano我安装 capistrano 后,Rails 应用程序无法加载
【发布时间】:2013-02-16 02:52:20
【问题描述】:

我第一次尝试在 vexxhost 上部署我的 rails 应用程序。我使用 github 作为我的源代码管理和 capistrano。

这是我的部署文件

require 'bundler/capistrano'
require 'capistrano'
require 'bundler'
require 'capistrano-vexxhost'

# Account Settings

ssh_options[:forward_agent] = true
set :scm_command, "/home/user/opt/bin/git"
set :local_scm_command,"git"
set :user, "xxxxxxxx"
set :password, "xxxxxxxxx"
set :domain, "domain.com"
set :mount_path,"/home/xxxxxxxx/xxxxxxx"
set :application,"app name"
set :scm, :git
set :deploy_via, :copy
set :repository, "git@github.com:xxxxx/xxxxxxx.git"
default_run_options[:pty] = true

当我安装 gem 'capistrano' gem 'capistrano-vexxhost' 后,尝试在笔记本电脑上本地加载我的应用程序时出现以下错误(在安装 capistrano 之前它正在工作)。

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/capistrano-2.14.1/lib/capistrano/configuration/loading.rb:18:in `instance': Please require this file from within a Capistrano recipe (LoadError) 
  from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/capistrano.rb:7:in `<top (required)>'
    from C:/Users/mummy/LagoAds/config/application.rb:6:in `require'
    from C:/Users/mummy/LagoAds/config/application.rb:6:in `<top (required)>'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:53:in `require'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:53:in `block in <top (required)>'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:50:in `tap'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

注意但是,当我在 application.rb 文件中的以下代码中注释 Bundler.require 行时,它会成功运行但无法识别 gems

 if defined?(Bundler)
 # If you precompile assets before deploying to production, use this line
 Bundler.require(*Rails.groups(:assets => %w(development test)))
 # If you want your assets lazily compiled in production, use this line
 # Bundler.require(:default, :assets, Rails.env)
 end

更新

当我输入以下代码“rake --trace”时,它也会给我以下错误

 rake aborted!
 please require the file from withen a capistrano recipe

请帮我解决这个问题

【问题讨论】:

    标签: ruby-on-rails-3.2 capistrano bundle rvm-capistrano


    【解决方案1】:

    如果您将 capistrano* gems 放入 Gemfile 您需要禁用自动要求:

    gem 'capistrano-vexxhost', :require => false
    

    【讨论】:

    • 感谢您的回答,我尝试了您的建议,但仍然遇到同样的错误。我认为这个问题与 BUNDLER 有关,因为当我从 application.rd 注释掉“Bundler.require(*Rails.groups(:assets => %w(development test)))”行时,它可以工作但没有t 加载宝石。
    • 您是否已将此添加到所有capistrano 相关的宝石中?
    • 耶耶耶!!!你是对的。现在可以了。但我想知道,“:require=> false”有什么作用,我希望它不会影响我部署到剪切服务器。
    • 它指示Bundler 不自动需要这些宝石
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-18
    • 2016-03-08
    • 2016-02-27
    • 1970-01-01
    • 2018-03-02
    • 1970-01-01
    • 2012-05-10
    相关资源
    最近更新 更多