-
Notifications
You must be signed in to change notification settings - Fork 366
Enforce ruby and bundler versions #4545
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
base: main
Are you sure you want to change the base?
Conversation
46b87bc to
a50bc0d
Compare
|
I've looked around a bit and could not find any big ruby project which specifies the bundler version in the Gemfile but also don't see any harm in it. For air-gapped envs this could be beneficial to detect version mismatches earlier. From my point this can be merged. |
a50bc0d to
2014891
Compare
|
FYI: I've created an action [1] that sets the [1] https://github.com/cloudfoundry/cloud_controller_ng/actions/workflows/bump_bundler_version.yml |
Co-authored-by: Johannes Haass <[email protected]>
This reverts commit 728f705.
385ba16 to
c8325f2
Compare
|
That seems like a good plan until we ever decide to desync bundler and the Ruby version (which we might want to do to upgrade to 3.3). I updated this PR to account for the bump to Ruby 3.2.9. Should I remove the inclusion of bundler in the Gemfile? |
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 WITHversion in the Gemfile.lock is bumped beyond the default, meaning that when it comes time to runbundlein 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 WITHversion 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
mainbranchI have run all the unit tests using
bundle exec rakeI have run CF Acceptance Tests