Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI fails with with different bundler execution #961

Merged
merged 2 commits into from
Mar 12, 2020

Conversation

schneems
Copy link
Contributor

I'm not 100% sure why this failure mode happens, but it looks like for some reason even though the path is set correctly bundler incorrectly uses the wrong path to load the wrong version of Ruby (the buildpack Ruby version instead of the Ruby version the customer's app wants/needs).

This is what the failure mode looks like:

# test setup
-----> Fetching heroku/ruby buildpack...
       buildpack downloaded
-----> Ruby app detected
-----> Installing bundler 2.0.2
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Setting up Test for Ruby/Rack
-----> Using Ruby version: ruby-2.7.0
-----> Installing dependencies using bundler 2.0.2
# test actual

-----> Running Ruby buildpack tests...
-----> Installing bundler 1.17.3
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Running test: bundle exec rspec
bundler: failed to load command: rspec (/app/vendor/bundle/bin/rspec)
Bundler::RubyVersionMismatch: Your Ruby version is 2.6.5, but your Gemfile specified 2.7.0

From inside of a bin/support/test_ruby modified run:

$ which bundle 25c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-16/bin//bundle
$ bundle -v Bundler version 2.0.2

It appears that the test/support/test_ruby script is invoking bundler and in these cases the system bundle is being invoked instead of the customer's bundler version. This then causes the wrong version of Ruby to be loaded, presumably due to some coupling in the default Bundler ruby gem.

Internal tickets:

…r some reason even though the path is set correctly bundler incorrectly uses the wrong path to load the wrong version of Ruby (the buildpack Ruby version instead of the Ruby version the customer's app wants/needs).

This is what the failure mode looks like:

```
# test setup
-----> Fetching heroku/ruby buildpack...
       buildpack downloaded
-----> Ruby app detected
-----> Installing bundler 2.0.2
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Setting up Test for Ruby/Rack
-----> Using Ruby version: ruby-2.7.0
-----> Installing dependencies using bundler 2.0.2
```

```
# test actual

-----> Running Ruby buildpack tests...
-----> Installing bundler 1.17.3
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Running test: bundle exec rspec
bundler: failed to load command: rspec (/app/vendor/bundle/bin/rspec)
Bundler::RubyVersionMismatch: Your Ruby version is 2.6.5, but your Gemfile specified 2.7.0
```

From inside of a `bin/support/test_ruby` modified run:

```
$ which bundle 25c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-16/bin//bundle
$ bundle -v Bundler version 2.0.2
```

It appears that the `test/support/test_ruby` script is invoking bundler and in these cases the system `bundle` is being invoked instead of the customer's bundler version. This then causes the wrong version of Ruby to be loaded, presumably due to some coupling in the default Bundler ruby gem.

Internal tickets:

- https://heroku.support/834258
- https://heroku.support/834446
@schneems schneems force-pushed the schneems/ci-fails-with-ruby-265 branch from b71a8f5 to 4c7f0f7 Compare March 11, 2020 18:49
@schneems
Copy link
Contributor Author

Tests fail as expected:

       -----> Installing bundler 1.17.3
       -----> Removing BUNDLED WITH version in the Gemfile.lock
       -----> Running test: bundle exec rspec
       bundler: failed to load command: rspec (/app/vendor/bundle/bin/rspec)
       Bundler::RubyVersionMismatch: Your Ruby version is 2.6.5, but your Gemfile specified 2.7.0
         /tmp/tmp.BYAG6qhQv7/lib/ruby/2.6.0/bundler/definition.rb:495:in `validate_ruby!'
         /tmp/tmp.BYAG6qhQv7/lib/ruby/2.6.0/bundler/definition.rb:470:in `validate_runtime!'
         /tmp/tmp.BYAG6qhQv7/lib/ruby/2.6.0/bundler.rb:101:in `setup'
         /tmp/tmp.BYAG6qhQv7/lib/ruby/2.6.0/bundler/setup.rb:20:in `<top (required)>'
         /tmp/tmp.BYAG6qhQv7/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
         /tmp/tmp.BYAG6qhQv7/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
       -----> Ruby buildpack tests failed with exit status 1
     # ./vendor/bundle/ruby/2.6.0/gems/heroku_hatchet-4.1.0/lib/hatchet/test_run.rb:122:in `block in wait!'
     # ./vendor/ruby-2.6.5/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'

Ruby 2.6+ ships with a version of bundler. If we do not ensure that the customer's `bundle` binary is on the path before the Ruby buildpack's then the buildpacks version may be used.

This PR prevents this problem by ensuring that the vendored customer version of bundler is always first in the path before any existing binaries and after the customers `bin/` dir.

# Do not modify or remove the line above.
# Everything below it will be ignored.
#
# Date:      Wed Mar 11 14:07:17 2020 -0500
#
# interactive rebase in progress; onto f20f977
# Last commands done (3 commands done):
#    pick 0b5e9f8 Force user's bundler on the path
#    squash d51fa3b Blerg
# No commands remaining.
# You are currently rebasing branch 'schneems/ci-fails-with-ruby-265' on 'f20f977'.
#
# Changes to be committed:
#       modified:   bin/support/ruby_test
#
@schneems schneems merged commit 12bac81 into master Mar 12, 2020
@schneems schneems deleted the schneems/ci-fails-with-ruby-265 branch March 12, 2020 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants