ruby / setup-ruby

An action to download a prebuilt Ruby and add it to the PATH in 5 seconds
https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
MIT License
804 stars 263 forks source link

NoMethodError: undefined method `to_gemfile' for an instance of Bundler::Source::Path #649

Closed rgaufman closed 1 month ago

rgaufman commented 1 month ago

Ensure the following before filing this issue

Are you running on a GitHub-hosted runner or a self-hosted runner?

GitHub-hosted runner

Any other notes?

This is my job in github-actions:

  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - uses: webfactory/ssh-agent@v0.9.0
        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
      - name: Install Ruby and gems
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true

      - name: Lint Ruby files
        run: bundle exec rubocop --parallel

When I run it, it fails with this:

Run ruby/setup-ruby@v1
  with:
    bundler-cache: true
    ruby-version: default
  env:
    ImageOS: macos15
    SSH_AUTH_SOCK: /tmp/ssh-XXXXXXCnKbT[2](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:2)/agent.1616
    SSH_AGENT_PID: 1617
Using [3](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:3).3.5 as input from file .ruby-version
Modifying PATH
Downloading Ruby
Extracting  Ruby
Print Ruby version
Installing Bundler
> bundle install
/opt/hostedtoolcache/Ruby/3.3.5/x6[4](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:4)/bin/bundle config --local path /home/runner/work/tetherx/tetherx/vendor/bundle
/opt/hostedtoolcache/Ruby/3.3.[5](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:5)/x64/bin/bundle config --local deployment true
Cache key: setup-ruby-bundler-cache-v[6](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:6)-ubuntu-22.04-x64-ruby-3.3.5-wd-/home/runner/work/tetherx/tetherx-with--without--only--Gemfile.lock-a6d525e2f4f8f211b49e943594ee0e6e2860[7](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:7)d88af52dddf5609c05491480315
/opt/hostedtoolcache/Ruby/3.3.5/x64/bin/bundle install --jobs 4
--- ERROR REPORT TEMPLATE -------------------------------------------------------

NoMethodError: undefined method `to_gemfile' for an instance of Bundler::Source::Path
  /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/definition.rb:39[8](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:8):in `block in ensure_equivalent_gemfile_and_lockfile'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/definition.rb:3[9](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:10)1:in `each'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/definition.rb:391:in `ensure_equivalent_gemfile_and_lockfile'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/installer.rb:72:in `block in run'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/process_lock.rb:12:in `block in lock'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/process_lock.rb:9:in `open'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/process_lock.rb:9:in `lock'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/installer.rb:71:in `run'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/installer.rb:23:in `install'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/cli/install.rb:68:in `run'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/cli.rb:247:in `block in install'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/settings.rb:158:in `temporary'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/cli.rb:246:in `install'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/cli.rb:35:in `dispatch'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/cli.rb:29:in `start'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/exe/bundle:28:in `block in <top (required)>'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/exe/bundle:20:in `<top (required)>'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/bin/bundle:25:in `load'
          /opt/hostedtoolcache/Ruby/3.3.5/x64/bin/bundle:25:in `<main>'

## Environment

Bundler       2.5.20
  Platforms   ruby, x86_64-linux
Ruby          3.3.5p[10](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:11)0 (2024-09-03 revision ef084cc8f4958c1b6e4ead99[13](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:15)6631bef6d8ddba) [x86_64-linux]
  Full Path   /opt/hostedtoolcache/Ruby/3.3.5/x64/bin/ruby
  Config Dir  /opt/hostedtoolcache/Ruby/3.3.5/x64/etc
RubyGems      3.5.[16](https://github.com/tetherit/tetherx/actions/runs/11054028038/job/30709824121#step:4:19)
  Gem Home    /home/runner/work/tetherx/tetherx/vendor/bundle/ruby/3.3.0
  Gem Path    /home/runner/work/tetherx/tetherx/vendor/bundle/ruby/3.3.0
  User Home   /home/runner
  User Path   /home/runner/.local/share/gem/ruby/3.3.0
  Bin Dir     /home/runner/work/tetherx/tetherx/vendor/bundle/ruby/3.3.0/bin
OpenSSL       
  Compiled    OpenSSL 3.0.2 15 Mar 2022
  Loaded      OpenSSL 3.0.2 15 Mar 2022
  Cert File   /usr/lib/ssl/cert.pem
  Cert Dir    /usr/lib/ssl/certs
Tools         
  Git         2.46.1
  RVM         not installed
  rbenv       not installed
  chruby      not installed
...

Any ideas?

eregon commented 1 month ago

Clearly it's not a setup-ruby issue, probably a Bundler issue.

eregon commented 1 month ago

I think the output even tells you to report it to Bundler, but that part has been cut.

rgaufman commented 1 month ago

Not a bundler issue, bundler works on multiple Linux and Mac Ruby installations with this source

~/tetherx $ /opt/homebrew/opt/ruby/bin/bundle install --jobs 4
Updating files in vendor/cache
Bundle complete! 154 Gemfile dependencies, 335 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
1 installed gem you directly depend on is looking for funding.
  Run `bundle fund` for details
~/tetherx $ echo $?
0
~/tetherx $  /opt/homebrew/opt/ruby/bin/bundle --version
Bundler version 2.5.20
~/tetherx $  ruby --version
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [arm64-darwin23]
rgaufman commented 1 month ago

I also tried with several versions of Ruby and Bundler. All work fine outside of the hosted instance and fails when switching to hosted instance. As a temporary solution I'm running on my local machine:

name: "Ruby on Rails CI"
on: [push, pull_request]
jobs:
  lint:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v4
      - run: echo /opt/homebrew/opt/ruby/bin >> $GITHUB_PATH
      - run: bundle install
      - run: bundle exec rubocop --parallel

In any case, I created a ticket with RubyGems: https://github.com/rubygems/rubygems/issues/8077