Repository navigation
Running bundle install without cache invokes the wrong version #440
Description
Activity
- is the logic that picks Bundler 1 even though Bundler 2 is installed.
Lines 159 to 160 in ad718fa
console.log(`Setting BUNDLER_VERSION=${bundlerVersion} for "bundle config|lock" commands below to ensure Bundler 1 is used`) envOptions = { env: { ...process.env, BUNDLER_VERSION: bundlerVersion } }
I guess we could globally export BUNDLER_VERSION and do that logic earlier, just after installing Bundler.Interestingly it would probably also work when installing latest Bundler and with a Gemfile.lock BUNDLED WITH 1.x, due to Bundler auto-switching. But that wouldn't work for older Ruby versions, so probably not helpful for setup-ruby.
Does it work if you use this? And if so, why not use that for the gem?
- name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 bundler: 1 bundler-cache: true
I'll fix this, makes sense to move that code there and export it globally.
The small advantage of only doing it previously for bundle config|lock was it was not necessary after because after the Gemfile.lock is enough to use the right Bundler version.
- added a commit that references this issue
on Jan 6, 2023 Does it work if you use this? And if so, why not use that for the gem?
- name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 bundler: 1 bundler-cache: true
That's exactly what I did in mongoid/mongoid-grid_fs#81 and it works well. I opened the issue because semantically
bundler-cachedoesn't really tell mebundle installand I don't want a cache because of the whole versioning/stuck with a bad cache problem, I just want ruby-setup to runbundle installfor me. I think aside from the bug (thanks for fixing it!) you wantbundler-install: true/falseandbundler-cache: true/false(bundler-cache: truecould requirebundler-install=true).I don't want a cache because of the whole versioning/stuck with a bad cache problem
AFAIK there is no such problem in practice with setup-ruby with many usages.
Did you see something specific? Otherwise please usebundler-cache: true, it's much less demanding on RubyGems.org servers and it's much faster.Re bundler-install/bundler-cache, that's been designed on purpose. I wouldn't want
bundler-install: true, people would come blaming this action when they can do it themselves with a single line.
And also it encourages to use bundler-cache which is the right thing to do.The docs seem abundantly clear about this as well: https://github.com/ruby/setup-ruby#caching-bundle-install-automatically
Thanks! Makes sense.
I will revert this, it is causing more troubles (#444 (comment)) than it helps.
Because basically it creates global state (the BUNDLER_VERSION env var) which cannot be cleaned by setup-ruby properly.Also it only fixes a very niche use-case of no bundler-cache, Ruby 2.7+ and Bundler 1 (EOL for a while).
I think it's completely fine for that niche use-case that users need to set BUNDLER_VERSION manually, they also need to do that locally anyway.
And I really don't mind that this encourages using bundler-cache of course :)Reacted by RyanRennCN and Patrik RagnarssonThanks @eregon.
- added a commit that references this issue
on Mar 11, 2025
Ensure the following before filing this issue
I verified it reproduces with the latest version with
- uses: ruby/setup-ruby@v1(see Versioning policy)I tried to reproduce the issue locally by following the workflow steps (including all commands done by
ruby/setup-ruby, except forDownloading Ruby&Extracting Ruby),and it did not reproduce locally (if it does reproduce locally, it's not a ruby/setup-ruby issue)
Are you running on a GitHub-hosted runner or a self-hosted runner?
GitHub-hosted runner
The workflow code or a link to the workflow file
Link to the log of a failed workflow job, or to a gist with the output
https://github.com/mongoid/mongoid-grid_fs/actions/runs/3851022104/jobs/6561793839
The command and output of the failing step
Any other notes?
When specifying a version of bundler without
bundler-cacheone must runbundle install. With this setup that invokes another version of bundler.It's probably not a bug, or possibly a feature request.
install: true/falsethat would do what bundler-cache: true does minus the cache (run bundle install).BUNDLE_GEMFILE? Need to verify.