thoughtbot / appraisal

A Ruby library for testing your library against different versions of dependencies.
https://thoughtbot.com
MIT License
1.25k stars 107 forks source link

Errno::ENOENT on install with Ruby 3.2 #199

Closed marcotc closed 1 year ago

marcotc commented 1 year ago
docker run --rm -it ruby:3.2.0-slim-bullseye /bin/bash # sha256:5f509291214bb3d88d3fd490256860f09fbed9c3f8192aa715d95576018f9d91
# then inside the container
echo "source 'https://rubygems.org'; gem 'appraisal'" > Gemfile
bundle install
echo "appraise 'group' do gem 'os' end" > Appraisals
bundle exec appraisal install

Actual

>> bundle check --gemfile='/gemfiles/group.gemfile' || bundle install --gemfile='/gemfiles/group.gemfile' --retry 1
The Gemfile's dependencies are satisfied
bundler: failed to load command: appraisal (/usr/local/bundle/bin/appraisal)
/usr/local/bundle/gems/appraisal-2.4.1/lib/appraisal/appraisal.rb:102:in `read': No such file or directory @ rb_sysopen - /gemfiles/group.gemfile.lock (Errno::ENOENT)
    from /usr/local/bundle/gems/appraisal-2.4.1/lib/appraisal/appraisal.rb:102:in `relativize'
    from /usr/local/bundle/gems/appraisal-2.4.1/lib/appraisal/cli.rb:61:in `block in install'
    from /usr/local/bundle/gems/appraisal-2.4.1/lib/appraisal/appraisal_file.rb:27:in `each'
    from /usr/local/bundle/gems/appraisal-2.4.1/lib/appraisal/appraisal_file.rb:27:in `each'
    from /usr/local/bundle/gems/appraisal-2.4.1/lib/appraisal/appraisal_file.rb:11:in `each'
    from /usr/local/bundle/gems/appraisal-2.4.1/lib/appraisal/cli.rb:59:in `install'
    from /usr/local/bundle/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /usr/local/bundle/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /usr/local/bundle/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /usr/local/bundle/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
    from /usr/local/bundle/gems/appraisal-2.4.1/bin/appraisal:8:in `<top (required)>'
    from /usr/local/bundle/bin/appraisal:25:in `load'
    from /usr/local/bundle/bin/appraisal:25:in `<top (required)>'
    from /usr/local/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `load'
    from /usr/local/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'
    from /usr/local/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
    from /usr/local/lib/ruby/3.2.0/bundler/cli.rb:491:in `exec'
    from /usr/local/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from /usr/local/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /usr/local/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    from /usr/local/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
    from /usr/local/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from /usr/local/lib/ruby/3.2.0/bundler/cli.rb:28:in `start'
    from /usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.1/libexec/bundle:45:in `block in <top (required)>'
    from /usr/local/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
    from /usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.1/libexec/bundle:33:in `<top (required)>'
    from /usr/local/bin/bundle:25:in `load'
    from /usr/local/bin/bundle:25:in `<main>'

It's interesting to note that The Gemfile's dependencies are satisfied is printed, but not accurate, since the example gem os is not installed yet.

Expected

Running with docker run --rm -it ruby:3.1.3-slim-bullseye /bin/bash I get:

bundle check --gemfile='/gemfiles/group.gemfile' || bundle install --gemfile='/gemfiles/group.gemfile' --retry 1
Bundler can't satisfy your Gemfile's dependencies.
Install missing gems with `bundle install`.
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Using rake 13.0.6
Using thor 1.2.1
Using bundler 2.3.26
Fetching os 1.1.4
Using appraisal 2.4.1
Installing os 1.1.4
Bundle complete! 2 Gemfile dependencies, 5 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
skaes commented 1 year ago

still broken with the released Ruby 3.2.0

Maimer commented 1 year ago

This seems to be an issue with bundler version >= 2.4. Since Ruby 3.2 comes with the default bundler of 2.4.1 it breaks when running the bundle exec appraisal install command as the bundle check command no longer generates a lockfile. I have done some digging, but it's unclear to me why this behavior changed in bundler and the bundle check command.

I tested this fix: https://github.com/thoughtbot/appraisal/pull/200 as well as this fix: https://github.com/thoughtbot/appraisal/pull/201 and both seem to work. Seems like it's related to this change: https://github.com/rubygems/rubygems/pull/6025.

@nickcharlton thoughts?

nickcharlton commented 1 year ago

I've merged in #202, could someone try with that and see if it's still an issue?

Maimer commented 1 year ago

I've merged in #202, could someone try with that and see if it's still an issue?

@nickcharlton just tested it and it worked for me. Thanks!

skaes commented 1 year ago

@nickcharlton works fine for me. tested with Ruby 2.7, 3.0, 3.1 and 3.2.

nickcharlton commented 1 year ago

Great, thanks for letting me know!

I'm going to close this now but we'll add Ruby 3.2 to CI soon.

petergoldstein commented 1 year ago

Any chance we can get a release that includes this fix soon? It would fix a number of GitHub Actions CI pipelines that are currently broken.

nickcharlton commented 1 year ago

It won't be long — I'd like to resolve #188 first, which I have in progress currently.

In the short-term, you could do something like: https://github.com/thoughtbot/administrate/pull/1932 and pin against main.