Enforce ruby and bundler versions #4545
Open
+7
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
There's some tricky behaviour with the CAPI pre-packaging/packaging process and how it uses Bundler that I think can be particularly confusing, especially to those new to contributing to CCNG that'd I'd like to document here and hopefully mitigate with this PR.
Cloud Controller must always use the default Bundler version with its Ruby version, or CAPI releases will not work on air-gapped environments.
This happens if a the
BUNDLED WITH
version in the Gemfile.lock is bumped beyond the default, meaning that when it comes time to runbundle
in the packaging step, bundler will notice that it does not have the correct version, attempt to download the right version, and fail.I think these issues can be mitigated by adding the Bundler and Ruby versions to our Gemfile.
Adding bundler to our Gemfile:
If you try to create a dev release with a different version (say you accidentally chruby'd 3.3 so now Bundler is 2.5.X), you get an error during prepackaging:
It also won't be possible to bump Gemfile.lock to a new
BUNDLED WITH
version during abundle update
.Adding bundler to our Gemfile may allow us to use newer versions of Bundler than what's the Ruby version's default because now the Bundler gem will be vendored like the others and the compilation VM won't need to download it. But I'd have to test on an air-gapped env just to be sure.
That said, I did find this solution relatively inconsistent--there were times where I thought creating a new release would error out because of the Bundler version I had selected, and it was somehow able to succeed.
Adding Ruby version to our Gemfile
Because of the prepackaging step, creating a CAPI bosh release (in this context, usually for testing) is reliant on having the correct Ruby version selected. This might manifest in errors during runtime or compilation, but I've seen this fail most frequently because the wrong Bundler version would be inadvertently selected, and gems would be vendored/packaged with Bundler 2.5, which would hit this bug with Bundler 2.5.
That makes this a little redundant with adding the Bundler version to the Gemfile, but adding the Ruby version to the Gemfile will instead will fail quickly during prepackaging with a clear message:
It will also raise an error if someone tries to run CCNG tests (or
bundle install
, etc) with the wrong Ruby version.I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
main
branchI have run all the unit tests using
bundle exec rake
I have run CF Acceptance Tests