【问题标题】:Why does heroku skip gems under development section in the gemfile?为什么heroku会跳过gemfile中开发部分下的gem?
【发布时间】:2015-11-18 09:18:41
【问题描述】:

我遇到了应用程序错误,所以检查了heroku rails console

(master)$ heroku run rails console
Running rails console on morning-river-1349... up, run.8048
/app/vendor/ruby-2.2.3/lib/ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'spring' (= 1.1.3) among 58 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/app/vendor/bundle/ruby/2.2.0:/app/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0', execute `gem env` for more information
    from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/rubygems/dependency.rb:324:in `to_spec'
    from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
    from /app/bin/spring:12:in `<top (required)>'
    from /app/bin/rails:4:in `load'
    from /app/bin/rails:4:in `<main>'

解决方案:我不得不将 spring 开发部分移到 gemfile 中的 main 部分。

现在应用运行良好,但是, 关于如何防止heroku跳过开发类别宝石的任何想法?
edit :抱歉给您带来不必要的麻烦,我阅读了 rails 4.1 {since then spring is preloaded} 的发行说明,因此将其包含在 gemfile 中会造成不必要的问题,因此将其完全删除。

【问题讨论】:

    标签: ruby-on-rails ruby heroku gem


    【解决方案1】:

    Heroku 是您的生产环境,因此您的 Gemfile 中的 developmenttest 组中的 Gem 永远不会安装在 Heroku 上。

    这就是Groups in Bundler 的全部意义——您不需要在生产服务器上耗尽内存的测试或开发相关 gem。

    Spring 是一个应用程序预加载器,可帮助您加快开发工作流程,因此您不应在生产环境中安装 Spring。尝试找出需要 Spring 的内容,并首先解决该问题。

    【讨论】:

    • 我明白这一点,但是我很困惑,因为当我使用 cloud 9 IDE 时,完全相同的代码在 heroku 上运行良好。但是,当我尝试对本地设置的 ubuntu 开发环境执行相同操作时,它不起作用。这让我想到了,无论如何谢谢你的回答。
    • Spring 文档明确指出“您不得在生产环境中安装 Spring”。 github.com/rails/spring#user-content-deployment 谷歌搜索您与“to_specs”相关的错误。我认为您应该找到对您的配置有帮助的东西。
    【解决方案2】:

    只是添加一些上下文,问题不是heroku,而是bundler

    Bundler 允许您安装特定于您工作环境的 gem:

    bundler install --without production staging test
    

    这对于多种类型的依赖关系非常方便(例如不同的 Web 服务器等):

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多