Repository navigation
Running bundle install without cache invokes the wrong version #440
Copy link
Copy link
Closed as not planned
Description
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
env:
BUNDLE_GEMFILE: gemfiles/xyz.gemfile
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler: 1.3
bundler-cache: false
- name: Bundle Install
run: bundle installLink 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
2023-01-05T22:58:48.5434775Z ##[group]Run ruby/setup-ruby@v1
2023-01-05T22:58:48.5435267Z with:
2023-01-05T22:58:48.5435584Z ruby-version: 2.7
2023-01-05T22:58:48.5435916Z bundler: 1.17.3
2023-01-05T22:58:48.5436535Z bundler-cache: false
2023-01-05T22:58:48.5436925Z env:
2023-01-05T22:58:48.5437280Z BUNDLE_GEMFILE: gemfiles/mongoid-5.0.gemfile
2023-01-05T22:58:48.5437648Z ##[endgroup]
2023-01-05T22:58:49.0015831Z ##[group]Modifying PATH
2023-01-05T22:58:49.0023871Z Entries added to PATH to use selected Ruby:
2023-01-05T22:58:49.0028914Z /opt/hostedtoolcache/Ruby/2.7.7/x64/bin
2023-01-05T22:58:49.0032710Z ##[endgroup]
2023-01-05T22:58:49.0085952Z ##[group]Downloading Ruby
2023-01-05T22:58:49.0087105Z https://github.com/ruby/ruby-builder/releases/download/toolcache/ruby-2.7.7-ubuntu-22.04.tar.gz
2023-01-05T22:58:49.2916086Z Took 0.28 seconds
2023-01-05T22:58:49.2916900Z ##[endgroup]
2023-01-05T22:58:49.2917701Z ##[group]Extracting Ruby
2023-01-05T22:58:49.2957419Z [command]/usr/bin/tar -xz -C /opt/hostedtoolcache/Ruby/2.7.7 -f /home/runner/work/_temp/2582c095-29c0-4938-8306-99549f14f10a
2023-01-05T22:58:49.6933307Z Took 0.40 seconds
2023-01-05T22:58:49.6934257Z ##[endgroup]
2023-01-05T22:58:49.6934740Z ##[group]Print Ruby version
2023-01-05T22:58:49.6948632Z [command]/opt/hostedtoolcache/Ruby/2.7.7/x64/bin/ruby --version
2023-01-05T22:58:49.7159731Z ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-linux]
2023-01-05T22:58:49.7179262Z Took 0.03 seconds
2023-01-05T22:58:49.7183549Z ##[endgroup]
2023-01-05T22:58:49.7189506Z ##[group]Installing Bundler
2023-01-05T22:58:49.7202362Z [command]/opt/hostedtoolcache/Ruby/2.7.7/x64/bin/gem install bundler -v 1.17.3
2023-01-05T22:58:50.3153955Z Successfully installed bundler-1.17.3
2023-01-05T22:58:50.3155223Z 1 gem installed
2023-01-05T22:58:50.3199889Z Took 0.60 seconds
2023-01-05T22:58:50.3200879Z ##[endgroup]
2023-01-05T22:58:50.3372171Z ##[group]Run bundle install
2023-01-05T22:58:50.3372532Z �[36;1mbundle install�[0m
2023-01-05T22:58:50.3441703Z shell: /usr/bin/bash -e {0}
2023-01-05T22:58:50.3441989Z env:
2023-01-05T22:58:50.3442280Z BUNDLE_GEMFILE: gemfiles/mongoid-5.0.gemfile
2023-01-05T22:58:50.3442596Z ##[endgroup]
2023-01-05T22:58:52.7565060Z Fetching gem metadata from https://rubygems.org/..........
2023-01-05T22:58:52.9455320Z Fetching gem metadata from https://rubygems.org/.
2023-01-05T22:58:53.1135416Z Resolving dependencies...
2023-01-05T22:58:53.1237167Z Bundler could not find compatible versions for gem "bundler":
2023-01-05T22:58:53.1238228Z In mongoid-5.0.gemfile:
2023-01-05T22:58:53.1238866Z rails (~> 4.0) was resolved to 4.2.11.3, which depends on
2023-01-05T22:58:53.1239427Z bundler (< 2.0, >= 1.3.0)
2023-01-05T22:58:53.1239751Z
2023-01-05T22:58:53.1240017Z Current Bundler version:
2023-01-05T22:58:53.1240460Z bundler (2.1.4)
2023-01-05T22:58:53.1241115Z This Gemfile requires a different version of Bundler.
2023-01-05T22:58:53.1242052Z Perhaps you need to update Bundler by running `gem install bundler`?
2023-01-05T22:58:53.1242555Z
2023-01-05T22:58:53.1243136Z Could not find gem 'bundler (< 2.0, >= 1.3.0)', which is required by gem 'rails
2023-01-05T22:58:53.1243754Z (~> 4.0)', in any of the sources.
2023-01-05T22:58:53.1244076Z
2023-01-05T22:58:53.1244416Z Bundler could not find compatible versions for gem "mongoid":
2023-01-05T22:58:53.1244957Z In mongoid-5.0.gemfile:
2023-01-05T22:58:53.1245455Z mongoid (~> 5.0.0)
2023-01-05T22:58:53.1245764Z
2023-01-05T22:58:53.1246233Z mongoid-grid_fs was resolved to 2.4.1, which depends on
2023-01-05T22:58:53.1246842Z mongoid (>= 3.0, < 9.0)
2023-01-05T22:58:53.1753230Z ##[error]Process completed with exit code 6.Any other notes?
When specifying a version of bundler without bundler-cache one must run bundle install. With this setup that invokes another version of bundler.
It's probably not a bug, or possibly a feature request.
- What i the right way to invoke bundle install with the version of bundler that was installed?
- Is this a feature request of adding
install: true/falsethat would do what bundler-cache: true does minus the cache (run bundle install). - Is this caused by having
BUNDLE_GEMFILE? Need to verify.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
eregon commentedon Jan 6, 2023
setup-ruby/bundler.js
Lines 159 to 160 in ad718fa
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?
eregon commentedon Jan 6, 2023
I'll fix this, makes sense to move that code there and export it globally.
eregon commentedon Jan 6, 2023
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.
Export BUNDLER_VERSION after installing Bundler
dblock commentedon Jan 6, 2023
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).eregon commentedon Jan 6, 2023
AFAIK there is no such problem in practice with setup-ruby with many usages.
Did you see something specific? Otherwise please use
bundler-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.
eregon commentedon Jan 6, 2023
The docs seem abundantly clear about this as well: https://github.com/ruby/setup-ruby#caching-bundle-install-automatically
dblock commentedon Jan 6, 2023
Thanks! Makes sense.
eregon commentedon Jan 10, 2023
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 :)
dblock commentedon Jan 10, 2023
Thanks @eregon.
Export BUNDLER_VERSION after installing Bundler