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

When executing RubySetup twice in the same job, the Bundler version is superseded by an env var set in the first RubySetup step.. #444

Closed
2 tasks done
RyanRennCN opened this issue Jan 10, 2023 · 4 comments

Comments

@RyanRennCN
Copy link

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 for Downloading 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

job:
    name: job
    runs-on: ubuntu-latest
    env:
      GITHUB_REGISTRY_AUTH_TOKEN: "${{ secrets.GH_TOKEN }}"
      BUNDLE_GITHUB__COM: "${{ secrets.GH_TOKEN }}:x-oauth-basic"
      RAILS_ENV: test
    steps:
      - uses: actions/checkout@v3

      - name: Install apt deps
        run: sudo apt -y install --no-install-recommends freetds-dev libxslt-dev

      - name: Set up Ruby for First Folder
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '2.7.2'
          bundler-cache: true
          working-directory: ./first_folder
      
      - name: Set up Ruby for Second Folder
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '2.7.2'
          bundler-cache: true
          bundler: '2.1.4'
          working-directory: ./second_folder
*** the rest of the job has been removed because of irrelevance***

Link to the log of a failed workflow job, or to a gist with the output

Not sure how to provide this (and I dont believe I can) since it is from a private repo.

The command and output of the failing step

* First Step
2023-01-09T19:18:29.1672560Z ##[group]Run ruby/setup-ruby@v1
2023-01-09T19:18:29.1673033Z with:
2023-01-09T19:18:29.1673339Z   ruby-version: 2.7.2
2023-01-09T19:18:29.1673660Z   bundler-cache: true
2023-01-09T19:18:29.1673957Z   working-directory: ./first_folder
2023-01-09T19:18:29.1674342Z env:
2023-01-09T19:18:29.1876982Z   KUBE_CONFIG_DATA: ***
2023-01-09T19:18:29.1877411Z   AWS_ACCESS_KEY_ID: ***
2023-01-09T19:18:29.1877826Z   AWS_SECRET_ACCESS_KEY: ***
2023-01-09T19:18:29.1878304Z   AWS_REGION: us-east-2
2023-01-09T19:18:29.1878923Z   GITHUB_REGISTRY_AUTH_TOKEN: ***
2023-01-09T19:18:29.1879402Z   BUNDLE_GITHUB__COM: ***:x-oauth-basic
2023-01-09T19:18:29.1879784Z   RAILS_ENV: test
2023-01-09T19:18:29.1880039Z ##[endgroup]
2023-01-09T19:18:29.3980582Z ##[group]Modifying PATH
2023-01-09T19:18:29.3984565Z Entries added to PATH to use selected Ruby:
2023-01-09T19:18:29.3986471Z   /opt/hostedtoolcache/Ruby/2.7.2/x64/bin
2023-01-09T19:18:29.3987440Z ##[endgroup]
2023-01-09T19:18:29.4023203Z ##[group]Downloading Ruby
2023-01-09T19:18:29.4025496Z https://github.com/ruby/ruby-builder/releases/download/toolcache/ruby-2.7.2-ubuntu-22.04.tar.gz
2023-01-09T19:18:30.0064682Z Took   0.60 seconds
2023-01-09T19:18:30.0065649Z ##[endgroup]
2023-01-09T19:18:30.0066761Z ##[group]Extracting  Ruby
2023-01-09T19:18:30.0106170Z [command]/usr/bin/tar -xz -C /opt/hostedtoolcache/Ruby/2.7.2 -f /home/runner/work/_temp/813bc68e-cfaf-4d52-b26f-11c88bbe946c
2023-01-09T19:18:30.4732429Z Took   0.47 seconds
2023-01-09T19:18:30.4734125Z ##[endgroup]
2023-01-09T19:18:30.4735174Z ##[group]Print Ruby version
2023-01-09T19:18:30.4757455Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/ruby --version
2023-01-09T19:18:30.4972317Z ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
2023-01-09T19:18:30.4990881Z Took   0.03 seconds
2023-01-09T19:18:30.4992185Z ##[endgroup]
2023-01-09T19:18:30.4998116Z ##[group]Installing Bundler
2023-01-09T19:18:30.5040135Z Using Bundler 1.17.3 from Gemfile.lock BUNDLED WITH 1.17.3
2023-01-09T19:18:30.5061550Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/gem install bundler -v 1.17.3
2023-01-09T19:18:31.2482543Z Successfully installed bundler-1.17.3
2023-01-09T19:18:31.2482985Z 1 gem installed
2023-01-09T19:18:31.2524764Z Setting BUNDLER_VERSION=1.17.3 to ensure Bundler 1 is used
2023-01-09T19:18:31.2533268Z Took   0.75 seconds
2023-01-09T19:18:31.2534500Z ##[endgroup]
2023-01-09T19:18:31.2535522Z ##[group]bundle install
2023-01-09T19:18:31.2562502Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/bundle config --local path /home/runner*obscured*
2023-01-09T19:18:31.4478256Z You are replacing the current local value of path, which is currently nil
2023-01-09T19:18:31.4537784Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/bundle config --local deployment true
2023-01-09T19:18:31.6483765Z You are replacing the current local value of deployment, which is currently nil
2023-01-09T19:18:31.6549237Z Cache key: setup-ruby-bundler-cache-v4-ubuntu-22.04-ruby-2.7.2-Gemfile.lock-beabd591ac824f6fdcbd548de8267979d0a800560fe4c2c3b4a1e9d72149976d
2023-01-09T19:18:33.0204988Z Received 37748736 of 777876678 (4.9%), 36.0 MBs/sec
2023-01-09T19:18:34.0257761Z Received 176160768 of 777876678 (22.6%), 83.7 MBs/sec
2023-01-09T19:18:35.0359401Z Received 314572800 of 777876678 (40.4%), 99.5 MBs/sec
2023-01-09T19:18:36.0366637Z Received 436207616 of 777876678 (56.1%), 103.6 MBs/sec
2023-01-09T19:18:37.0364502Z Received 570425344 of 777876678 (73.3%), 108.4 MBs/sec
2023-01-09T19:18:38.0364451Z Received 704643072 of 777876678 (90.6%), 111.7 MBs/sec
2023-01-09T19:18:40.3804430Z Received 777876678 of 777876678 (100.0%), 88.7 MBs/sec
2023-01-09T19:18:40.3808249Z Cache Size: ~742 MB (777876678 B)
2023-01-09T19:18:40.3855997Z [command]/usr/bin/tar --use-compress-program unzstd -xf *obscured*
2023-01-09T19:18:48.4671401Z Cache restored successfully
2023-01-09T19:18:48.6022676Z Found cache for key: setup-ruby-bundler-cache-v4-ubuntu-22.04-ruby-2.7.2-Gemfile.lock-beabd591ac824f6fdcbd548de8267979d0a800560fe4c2c3b4a1e9d72149976d
2023-01-09T19:18:48.6031941Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/bundle install --jobs 4
2023-01-09T19:18:49.5415894Z Using rake 13.0.6
…truncated…
2023-01-09T19:18:49.5468205Z Using activemodel 5.2.8
2023-01-09T19:18:49.5468448Z Using arel 9.0.0
2023-01-09T19:18:49.5468690Z Using activerecord 5.2.8
2023-01-09T19:18:49.5468933Z Using marcel 1.0.2
2023-01-09T19:18:49.5476378Z Using activestorage 5.2.8
2023-01-09T19:18:49.5476681Z Using bundler 1.17.3
…truncated…
2023-01-09T19:18:49.6587084Z Bundle complete! 158 Gemfile dependencies, 361 gems now installed.
2023-01-09T19:18:49.6587459Z Bundled gems are installed into `./vendor/bundle`
2023-01-09T19:18:49.6660910Z Took  18.41 seconds
2023-01-09T19:18:49.6661748Z ##[endgroup]

* Second Step
2023-01-09T19:19:18.8936286Z ##[group]Run ruby/setup-ruby@v1
2023-01-09T19:19:18.8936601Z with:
2023-01-09T19:19:18.8936841Z   ruby-version: 2.7.2
2023-01-09T19:19:18.8937095Z   bundler: 2.1.4
2023-01-09T19:19:18.8937349Z   bundler-cache: true
2023-01-09T19:19:18.8937624Z   working-directory: ./second_folder
2023-01-09T19:19:18.8937892Z env:
2023-01-09T19:19:18.9148297Z   KUBE_CONFIG_DATA: ***
2023-01-09T19:19:18.9148797Z   AWS_ACCESS_KEY_ID: ***
2023-01-09T19:19:18.9149190Z   AWS_SECRET_ACCESS_KEY: ***
2023-01-09T19:19:18.9149472Z   AWS_REGION: us-east-2
2023-01-09T19:19:18.9149844Z   GITHUB_REGISTRY_AUTH_TOKEN: ***
2023-01-09T19:19:18.9150226Z   BUNDLE_GITHUB__COM: ***:x-oauth-basic
2023-01-09T19:19:18.9150503Z   RAILS_ENV: test
2023-01-09T19:19:18.9150755Z   BUNDLER_VERSION: 1.17.3.   <-- You can see the env var is carried over from the first ruby setup step.
2023-01-09T19:19:18.9151011Z ##[endgroup]
2023-01-09T19:19:19.1366790Z ##[group]Modifying PATH
2023-01-09T19:19:19.1372005Z Entries removed from PATH to avoid conflicts with default Ruby:
2023-01-09T19:19:19.1373471Z   /opt/hostedtoolcache/Ruby/2.7.2/x64/bin
2023-01-09T19:19:19.1386966Z Entries added to PATH to use selected Ruby:
2023-01-09T19:19:19.1387757Z   /opt/hostedtoolcache/Ruby/2.7.2/x64/bin
2023-01-09T19:19:19.1388920Z ##[endgroup]
2023-01-09T19:19:19.1402150Z ##[group]Print Ruby version
2023-01-09T19:19:19.1465542Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/ruby --version
2023-01-09T19:19:19.1697745Z ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
2023-01-09T19:19:19.1735116Z Took   0.03 seconds
2023-01-09T19:19:19.1736281Z ##[endgroup]
2023-01-09T19:19:19.1739921Z ##[group]Installing Bundler
2023-01-09T19:19:19.1751176Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/gem install bundler -v 2.1.4
2023-01-09T19:19:19.8181787Z Successfully installed bundler-2.1.4
2023-01-09T19:19:19.8182168Z 1 gem installed
2023-01-09T19:19:19.8233106Z Took   0.65 seconds
2023-01-09T19:19:19.8234870Z ##[endgroup]
2023-01-09T19:19:19.8235704Z ##[group]bundle install
2023-01-09T19:19:19.8256095Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/bundle config --local path /home/runner/*obscured*
2023-01-09T19:19:20.0230433Z You are replacing the current local value of path, which is currently nil
2023-01-09T19:19:20.0358660Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/bundle config --local deployment true
2023-01-09T19:19:20.2399635Z You are replacing the current local value of deployment, which is currently nil
2023-01-09T19:19:20.2560779Z Cache key: setup-ruby-bundler-cache-v4-ubuntu-22.04-ruby-2.7.2-Gemfile.lock-5120c401d01baa3b95e79cf955916b97d4f07a28fcdffb492293441bb4921afe
2023-01-09T19:19:21.6146193Z Received 37748736 of 777876678 (4.9%), 36.0 MBs/sec
2023-01-09T19:19:22.6155534Z Received 171966464 of 777876678 (22.1%), 81.9 MBs/sec
2023-01-09T19:19:23.6161131Z Received 310378496 of 777876678 (39.9%), 98.6 MBs/sec
2023-01-09T19:19:24.6173174Z Received 457179136 of 777876678 (58.8%), 108.9 MBs/sec
2023-01-09T19:19:25.6178443Z Received 599785472 of 777876678 (77.1%), 114.3 MBs/sec
2023-01-09T19:19:26.6179452Z Received 754974720 of 777876678 (97.1%), 119.9 MBs/sec
2023-01-09T19:19:27.5764971Z Received 777876678 of 777876678 (100.0%), 106.5 MBs/sec
2023-01-09T19:19:27.5768500Z Cache Size: ~742 MB (777876678 B)
2023-01-09T19:19:27.5840029Z [command]/usr/bin/tar --use-compress-program unzstd -xf /home/runner/work/_temp/2d252970-e9ab-43d0-b8ed-ad72045f1621/cache.tzst -P -C /home/runner/work/*obscured*
2023-01-09T19:19:33.2114282Z Cache restored successfully
2023-01-09T19:19:33.3792791Z Found cache for key: setup-ruby-bundler-cache-v4-ubuntu-22.04-ruby-2.7.2-Gemfile.lock-beabd591ac824f6fdcbd548de8267979d0a800560fe4c2c3b4a1e9d72149976d
2023-01-09T19:19:33.3811973Z [command]/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/bundle install --jobs 4
2023-01-09T19:19:33.8387605Z You must use Bundler 2 or greater with this lockfile.     <-The env var is overriding the bundler version setting on the step.
2023-01-09T19:19:33.8419879Z Took  14.02 seconds
2023-01-09T19:19:33.8420884Z ##[endgroup]
2023-01-09T19:19:33.8524722Z ##[error]Error: The process '/opt/hostedtoolcache/Ruby/2.7.2/x64/bin/bundle' failed with exit code 20
    at ExecState._setResult (/home/runner/work/_actions/ruby/setup-ruby/v1/dist/index.js:5381:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/ruby/setup-ruby/v1/dist/index.js:5364:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ruby/setup-ruby/v1/dist/index.js:5258:27)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)

Any other notes?

With this most recent commit to add BUNDLER_VERSION after installing Bundler, it has impacted the behavior of one of our jobs where two different versions of bundler are used in two different sub-folders (two steps within in the same job).

The first one uses 1.17.3 and this commit then causes the action to write out an env var with this version that is then used by the second Setup Ruby action. I tried setting the bundler version as a Ruby input on the second action, but it seems that the env var overwrites it.

@eregon
Copy link
Member

eregon commented Jan 10, 2023

I see, thank you for the detailed report.
So for first_folder there is a Gemfile.lock BUNDLED WITH 1.17.3, which is why Bundler 1 is used (otherwise it would be Bundler 2 for both and BUNDLER_VERSION wouldn't be set at all).

Using ruby/setup-ruby twice in the same job is not really tested or supported currently, although I think it makes sense to support it as an easy way to use multiple Bundler caches. Yet, it's not as clean as using separate CI for that.
Are you able to share the reason why this is done as a single job instead of two?

Workarounds:

  • bundle update --bundler on the first Gemfile.lock, so it's not BUNDLED WITH 1.17.3 which is long time not supported anymore.
  • Maybe setting env: BUNDLER_VERSION: 2 for the second uses: ruby/setup-ruby@v1 might help until this is fixed

To fix this:

eregon added a commit that referenced this issue Jan 10, 2023
* This reverts commit 3190662.
* It causes other issues such as #444
  due to creating additional global state.
* The use-case it solves is too niche to risk such issues,
  using `bundler-cache: true` avoids the problem.
* See #444 (comment)
@eregon
Copy link
Member

eregon commented Jan 10, 2023

Solved by reverting 3190662

@eregon eregon closed this as completed Jan 10, 2023
@eregon
Copy link
Member

eregon commented Jan 10, 2023

@RyanRennCN
Copy link
Author

Thank you!

In terms of why this is done as one job vs two, I'm not sure offhand as I'm on the platform team, rather than the app team that manages this application. I would assume its because of dependencies between components in the first_folder and the second_folder. This is a mono repo, so the services are in different folders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants