Heroku uses older Ruby version when running `bundle install`

288 views Asked by At

I'm trying to run a Rails app on Ruby 2.7.1 on Heroku. Everything worked fine, then I changed something in my Gemfile to use Ruby 2.7's numbered parameters, and now the deploy fails with this error message:

remote: -----> Build succeeded!
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.0.2
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote:
remote:  !
remote:  !     There was an error parsing your Gemfile, we cannot continue
remote:  !
remote:  !     [!] There was an error parsing `Gemfile`: Undefined local variable or method `_1' for Gemfile. Bundler cannot continue.
remote:  !
remote:  !     #  from /tmp/build_6681cf5c/Gemfile:22
remote:  !     #  -------------------------------------------
remote:  !     #  dependencies.any? { _1.name == gem_name }
remote:  !     #  -------------------------------------------
remote:  !     . Bundler cannot continue.

It works fine locally and I've been using the same code in a few other Rails apps and deployment was never a problem.

Due to the error Undefined local variable or method '_1' for Gemfile. I assume a Ruby version < 2.7 is used when running bundle install. The app itself runs fine on Ruby 2.7.1 though:

$ heroku run "ruby -v"
Running ruby -v on ⬢ myapp... up, run.7979 (Free)
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

There are a few other similar questions here on SO, but they all deal with Heroku not respecting the Ruby version set in Gemfile or .ruby-version, which is not the problem for me, just during bundle install it seems to use a different Ruby version for some reason...

Is there any way to debug this further, or force Ruby 2.7 even during bundle install on deployment?

0

There are 0 answers