【问题标题】:Heroku bundler undefined method "present?", fails to install gems via bundlerHeroku bundler 未定义方法“存在?”,无法通过 bundler 安装 gem
【发布时间】:2021-08-26 19:33:12
【问题描述】:

在尝试将 rails 应用程序推送到 Heroku 时遇到一个奇怪的错误:

    remote: -----> Building on the Heroku-20 stack
    remote: -----> Using buildpack: heroku/ruby
    remote: -----> Ruby app detected
    remote: -----> Installing bundler 2.2.16
    remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
    remote: -----> Compiling Ruby/Rails
    remote: -----> Using Ruby version: ruby-3.0.1
    remote: -----> Installing dependencies using bundler 2.2.16
    remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
    remote:        /tmp/build_ae8e646d/bin/bundle:42:in `gemfile': undefined method `present?' for "/tmp/build_ae8e646d/Gemfile":String (NoMethodError)
    remote:        Did you mean?  prepend
    remote:         from /tmp/build_ae8e646d/bin/bundle:49:in `lockfile'
    remote:         from /tmp/build_ae8e646d/bin/bundle:57:in `lockfile_version'
    remote:         from /tmp/build_ae8e646d/bin/bundle:68:in `bundler_version'
    remote:         from /tmp/build_ae8e646d/bin/bundle:72:in `bundler_requirement'
    remote:         from /tmp/build_ae8e646d/bin/bundle:100:in `activate_bundler'
    remote:         from /tmp/build_ae8e646d/bin/bundle:88:in `load_bundler!'
    remote:         from /tmp/build_ae8e646d/bin/bundle:116:in `<main>'
    remote:        Bundler Output: /tmp/build_ae8e646d/bin/bundle:42:in `gemfile': undefined method `present?' for "/tmp/build_ae8e646d/Gemfile":String (NoMethodError)
    remote:        Did you mean?  prepend
    remote:         from /tmp/build_ae8e646d/bin/bundle:49:in `lockfile'
    remote:         from /tmp/build_ae8e646d/bin/bundle:57:in `lockfile_version'
    remote:         from /tmp/build_ae8e646d/bin/bundle:68:in `bundler_version'
    remote:         from /tmp/build_ae8e646d/bin/bundle:72:in `bundler_requirement'
    remote:         from /tmp/build_ae8e646d/bin/bundle:100:in `activate_bundler'
    remote:         from /tmp/build_ae8e646d/bin/bundle:88:in `load_bundler!'
    remote:         from /tmp/build_ae8e646d/bin/bundle:116:in `<main>'
    remote: 
    remote:  !
    remote:  !     Failed to install gems via Bundler.
    remote:  !
    remote:  !     Push rejected, failed to compile Ruby app.

在此之前,我已经将应用程序的脚手架部署到 Heroku,一切顺利。但是在工作了一段时间并推送更改后,出现了错误。

已经尝试重新生成 Gemlock.file 和包更新,但没有运气。在本地,一切正常。 Ruby 和 bundler 版本在本地和 Heroku 上是相同的。现在,不知道那可能是什么。有没有人遇到过这样的错误?

【问题讨论】:

    标签: ruby-on-rails heroku bundler


    【解决方案1】:

    找到了解决办法。问题是rubocop将/bin/bundle文件中的第42行修改为return gemfile if gemfile.present?,通过错误。我只是将它恢复到return gemfile if gemfile &amp;&amp; !gemfile.empty? 的初始状态,一切正常。希望,这会对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 2015-09-23
      • 2019-01-07
      • 2021-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      • 1970-01-01
      相关资源
      最近更新 更多