ruby / setup-ruby

An action to download a prebuilt Ruby and add it to the PATH in 5 seconds

Home Page:https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bundler install appears broken on Ruby 2.2

jeremyevans opened this issue · comments

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

Link to the failed workflow job (must be a public workflow job, so the necessary information is available)

https://github.com/jeremyevans/ruby-refrigerator/actions/runs/4716774683/jobs/8364821711

Any other notes?

This has failed in multiple projects, and appears to be a general issue with Ruby 2.2. Here's another example:
https://github.com/jeremyevans/sequel/actions/runs/4723218962/jobs/8378878032

Installation of bundler works locals:

$ gem22 install bundler -v '~> 1.0'
Fetching: bundler-1.17.3.gem (100%)
Successfully installed bundler-1.17.3
1 gem installed
$ ruby22 -v
ruby 2.2.10p489 (2018-03-28 revision 63023) [x86_64-openbsd]
$ gem22 -v
2.4.5.5

Example output:

Installing Bundler
  Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2
  /opt/hostedtoolcache/Ruby/2.2.10/x64/bin/gem install bundler -v ~> 1.0
  ERROR:  While executing gem ... (RuntimeError)
      Marshal.load reentered at marshal_load
  Took   0.36 seconds

Ruby 2.3.3 also appears to be affected by the issue.

2023-04-17T17:30:46.0486603Z ##[group]Run ruby/setup-ruby@v1
2023-04-17T17:30:46.0486903Z with:
2023-04-17T17:30:46.0487361Z   ruby-version: 2.3.3
2023-04-17T17:30:46.0487602Z   bundler-cache: true
2023-04-17T17:30:46.0487867Z env:
2023-04-17T17:30:46.0488171Z   QT_SELECT: qt4
2023-04-17T17:30:46.0488437Z ##[endgroup]
2023-04-17T17:30:46.2114536Z ##[group]Modifying PATH
2023-04-17T17:30:46.2118564Z Entries added to PATH to use selected Ruby:
2023-04-17T17:30:46.2130476Z   /opt/hostedtoolcache/Ruby/2.3.3/x64/bin
2023-04-17T17:30:46.2131462Z ##[endgroup]
2023-04-17T17:30:46.2167425Z ##[group]Downloading Ruby
2023-04-17T17:30:46.2169181Z https://github.com/ruby/ruby-builder/releases/download/toolcache/ruby-2.3.3-ubuntu-22.04.tar.gz
2023-04-17T17:30:46.7543496Z Took   0.54 seconds
2023-04-17T17:30:46.7544328Z ##[endgroup]
2023-04-17T17:30:46.7545248Z ##[group]Extracting  Ruby
2023-04-17T17:30:46.7578416Z [command]/usr/bin/tar -xz -C /opt/hostedtoolcache/Ruby/2.3.3 -f /home/runner/work/_temp/87846b30-9063-41ee-9910-30a959cf5edd
2023-04-17T17:30:47.6850393Z Took   0.93 seconds
2023-04-17T17:30:47.6851078Z ##[endgroup]
2023-04-17T17:30:47.6852502Z ##[group]Print Ruby version
2023-04-17T17:30:47.6861747Z [command]/opt/hostedtoolcache/Ruby/2.3.3/x64/bin/ruby --version
2023-04-17T17:30:47.7018200Z ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
2023-04-17T17:30:47.7061744Z Took   0.02 seconds
2023-04-17T17:30:47.7062883Z ##[endgroup]
2023-04-17T17:30:47.7063731Z ##[group]Installing Bundler
2023-04-17T17:30:47.7069881Z Using Bundler 1.17.3 from Gemfile.lock BUNDLED WITH 1.17.3
2023-04-17T17:30:47.7071074Z [command]/opt/hostedtoolcache/Ruby/2.3.3/x64/bin/gem install bundler -v 1.17.3
2023-04-17T17:30:48.0563788Z ERROR:  While executing gem ... (RuntimeError)
2023-04-17T17:30:48.0564473Z     Marshal.load reentered at marshal_load
2023-04-17T17:30:48.0623362Z Took   0.36 seconds
2023-04-17T17:30:48.0624528Z ##[endgroup]
2023-04-17T17:30:48.0654548Z ##[error]The process '/opt/hostedtoolcache/Ruby/2.3.3/x64/bin/gem' failed with exit code 1
2023-04-17T17:30:48.0910002Z Post job cleanup.

This is interesting.

  1. I see a workflow run that was fine in ruby-refrigerator just 18 hours ago. Note that both workflows used the same runner image version (20230409.1).
  2. setup-ruby hasn't had any changes since 04-Apr.
  3. I updated the ci.yml file in ruby-refrigerator, using Ubuntu-20.04, and also updating actions/checkout to v3. Ruby 2.2 passed.

Given the above, I have no idea what the issue is...

This is possibly related to the deprecation of the RubyGems dependencies API. There's a brownout today (2023-04-17). See https://blog.rubygems.org/2023/02/22/dependency-api-deprecation.html and https://blog.rubygems.org/2023/04/07/dependency-api-deprecation-delayed.html.

Ruby 2.1 has also been encountering issues (see #493).

Is this duplicate of #493 ?

This is clearly a RubyGems issue, would be best to file it there.

I filed this because I didn't think it was the same as #493 (for one, it didn't affect Ruby 2.1). However, looking at the comments in #493, it does seem to discuss the Marshal.load reentered at marshal_load issue. I'm fine closing this if maintainers want to track it in #493.

There's another rubygems.org Dependency API deprecation brownout today (April 24), so the Ruby 2.2 failures have reoccurred (example: https://github.com/jeremyevans/tilt/actions/runs/4782416382/jobs/8501734094). I tried installing bundler manually again on ruby 2.2 on a different system and still didn't have any problems:

$ gem22 install bundler -v '~> 1.0'                
Fetching: bundler-1.17.3.gem (100%)
Successfully installed bundler-1.17.3
Parsing documentation for bundler-1.17.3
Installing ri documentation for bundler-1.17.3
Done installing documentation for bundler after 10 seconds
1 gem installed

Maybe this is not the fault of setup-ruby, but I am unable to reproduce the problem outside of it.

Maybe one possible fix would be to add --ignore-dependencies to the gem install bundler call, at least on Ruby 2.2? bundler doesn't have any dependencies, and maybe this would avoid any potential issues with the rubygems.org Dependency API.

I tried to repro, but got a segfault instead: https://github.com/eregon/setup-ruby-test/actions/runs/4789939825/jobs/8518407285
I think it's time to drop Ruby 2.2 support to be honest.

I would guess recent compilers miscompile Ruby 2.2 and cause such segfault or wrong behavior (hooray for C undefined behavior).
I have no plans to use hacks/workarounds like using old compilers for setup-ruby.

So from the above runs it seems to always work on 20.04, and always fail on 22.04.
So a simple workaround for now is using ubuntu 20.04 for such old Rubies (and when 20.04 is removed there will be no way to get Ruby 2.2 to run on a GitHub-hosted Linux runner probably).

Even when using --ignore-dependencies it still segfaults on 22.04: https://github.com/eregon/setup-ruby-test/actions/runs/4790042844/jobs/8518648009

@eregon Thank you very much for testing and that information.