Ruby on rails Heroku bundler未定义方法“;现在;,无法通过bundler安装gems

Ruby on rails Heroku bundler未定义方法“;现在;,无法通过bundler安装gems,ruby-on-rails,heroku,bundler,Ruby On Rails,Heroku,Bundler,尝试将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: -----> Remo

尝试将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.
remote:------>在Heroku-20堆栈上构建
远程:-->使用buildpack:heroku/ruby
远程:-->检测到Ruby应用程序
远程:-->安装捆绑机2.2.16
远程:-->删除Gemfile.lock中的捆绑版本
远程:-->编译Ruby/Rails
远程:-->使用Ruby版本:Ruby-3.0.1
远程:-->使用bundler 2.2.16安装依赖项
远程:正在运行:BUNDLE\u而不使用='development:test'BUNDLE\u PATH=vendor/BUNDLE BUNDLE\u BIN=vendor/BUNDLE/BIN BUNDLE\u部署=1 BUNDLE安装-j4
远程:/tmp/build\u ae8e646d/bin/bundle:42:“gemfile”中:未定义“/tmp/build\u ae8e646d/gemfile”的方法“present”:字符串(NoMethodError)
遥控器:你是说?预编
远程:from/tmp/build_ae8e646d/bin/bundle:49:在“锁文件”中
远程:从/tmp/build_ae8e646d/bin/bundle:57:“锁定文件”版本中
远程:from/tmp/build_ae8e646d/bin/bundle:68:in'bundler_version'
远程:from/tmp/build_ae8e646d/bin/bundle:72:在“bundler_requirement”中
远程:从/tmp/build_ae8e646d/bin/bundle:100:“激活绑定器”中
远程:from/tmp/build_ae8e646d/bin/bundle:88:in'load_bundler!'
远程:from/tmp/build\u ae8e646d/bin/bundle:116:in`'
远程:绑定器输出:/tmp/build\u ae8e646d/bin/bundle:42:“gemfile”中:未定义“/tmp/build\u ae8e646d/gemfile”的方法“present”:字符串(命名错误)
遥控器:你是说?预编
远程:from/tmp/build_ae8e646d/bin/bundle:49:在“锁文件”中
远程:从/tmp/build_ae8e646d/bin/bundle:57:“锁定文件”版本中
远程:from/tmp/build_ae8e646d/bin/bundle:68:in'bundler_version'
远程:from/tmp/build_ae8e646d/bin/bundle:72:在“bundler_requirement”中
远程:从/tmp/build_ae8e646d/bin/bundle:100:“激活绑定器”中
远程:from/tmp/build_ae8e646d/bin/bundle:88:in'load_bundler!'
远程:from/tmp/build\u ae8e646d/bin/bundle:116:in`'
远程:
遥控器:!
遥控器:!无法通过捆绑程序安装gems。
遥控器:!
遥控器:!推送被拒绝,无法编译Ruby应用程序。
在此之前,我已经在Heroku上部署了一个应用程序框架,一切都很顺利。但经过一段时间的工作和推动的变化,错误出现了


已经尝试重新生成Gemlock.file和bundle更新,但没有成功。在当地,一切正常。Ruby和bundler版本在本地和Heroku上都是相同的。现在,我一点也不知道那会是什么。有人遇到过这样的错误吗?

找到了解决方案。问题是rubocop将/bin/bundle文件中的42行修改为
返回gemfile if gemfile.present?
,从而避免了错误。如果gemfile&&,我只是将其恢复为
return gemfile的初始状态!gemfile.empty?
一切正常。希望,这将帮助某人