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

Sorting in spec_set.rb works on Ruby 3.2.2 and fails on Ruby 3.3.0 due to nil member #7381

Closed
svoop opened this issue Jan 12, 2024 · 26 comments · Fixed by #7642
Closed

Sorting in spec_set.rb works on Ruby 3.2.2 and fails on Ruby 3.3.0 due to nil member #7381

svoop opened this issue Jan 12, 2024 · 26 comments · Fixed by #7642

Comments

@svoop
Copy link
Contributor

svoop commented Jan 12, 2024

Describe the problem as clearly as you can

I've just updated my NOTAM gem for Ruby 3.3.0 and hit a problem with Bundler.

Using Rubygems 3.5.4 and Bundler 2.5.4 on Ruby 3.3.0 both bundle install and bundle update raise:

NoMethodError: undefined method `name' for nil

The error happens on spec_set.rb line 269 where @spec contains a nil member sort_by doesn't like.

Reverting back to Ruby 3.2.2 while using the same versions of Rubygems and Bundler works fine.

Did you try upgrading rubygems & bundler?

Yes, all is up to date.

Error template

NoMethodError: undefined method `name' for nil
  /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:269:in `each'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:269:in `sort_by'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:269:in `tsort_each_node'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/tsort/lib/tsort.rb:350:in `call'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/tsort/lib/tsort.rb:350:in `each_strongly_connected_component'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/tsort/lib/tsort.rb:229:in `tsort_each'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/tsort/lib/tsort.rb:179:in `each'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/tsort/lib/tsort.rb:179:in `to_a'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/tsort/lib/tsort.rb:179:in `tsort'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/tsort/lib/tsort.rb:155:in `tsort'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:243:in `sorted'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:191:in `each'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/installer.rb:231:in `ensure_specs_are_compatible!'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/installer.rb:83:in `block in run'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/process_lock.rb:12:in `block in lock'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/process_lock.rb:9:in `open'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/process_lock.rb:9:in `lock'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/installer.rb:71:in `run'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/installer.rb:23:in `install'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/cli/update.rb:79:in `run'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:277:in `block in update'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/settings.rb:158:in `temporary'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:276:in `update'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:34:in `dispatch'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:28:in `start'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/exe/bundle:28:in `block in <top (required)>'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/site_ruby/3.3.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
          /Users/svoop/.rubies/ruby-3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/exe/bundle:20:in `<top (required)>'
          /Users/svoop/Development/ofm/notam/.direnv/bin/bundle:108:in `load'
          /Users/svoop/Development/ofm/notam/.direnv/bin/bundle:108:in `<main>'

Environment

Bundler       2.5.4
  Platforms   ruby, arm64-darwin-23
Ruby          3.3.0p0 (2023-12-25 revision 5124f9ac7513eb590c37717337c430cb93caa151) [arm64-darwin-23]
  Full Path   /Users/svoop/.rubies/ruby-3.3.0/bin/ruby
  Config Dir  /Users/svoop/.rubies/ruby-3.3.0/etc
RubyGems      3.5.4
  Gem Home    /Users/svoop/.gem/ruby/3.3.0
  Gem Path    /Users/svoop/.gem/ruby/3.3.0:/Users/svoop/.rubies/ruby-3.3.0/lib/ruby/gems/3.3.0
  User Home   /Users/svoop
  User Path   /Users/svoop/.gem/ruby/3.3.0
  Bin Dir     /Users/svoop/.gem/ruby/3.3.0/bin
OpenSSL
  Compiled    OpenSSL 3.2.0 23 Nov 2023
  Loaded      OpenSSL 3.2.0 23 Nov 2023
  Cert File   /opt/homebrew/etc/openssl@3/cert.pem
  Cert Dir    /opt/homebrew/etc/openssl@3/certs
Tools
  Git         2.42.1
  RVM         not installed
  rbenv       not installed
  chruby      not installed

Bundler Build Metadata

Built At          2024-01-04
Git SHA           7ffda9ba9b
Released Version  true

Bundler settings

--trust-policy
  Set for the current user (/Users/svoop/.bundle/config): "MediumSecurity"
bin
  Set via BUNDLE_BIN: "/Users/svoop/Development/ofm/notam/.direnv/bin"
  Set for the current user (/Users/svoop/.bundle/config): "bin"
gem.changelog
  Set for the current user (/Users/svoop/.bundle/config): true
gem.ci
  Set for the current user (/Users/svoop/.bundle/config): false
gem.coc
  Set for the current user (/Users/svoop/.bundle/config): false
gem.linter
  Set for the current user (/Users/svoop/.bundle/config): false
gem.mit
  Set for the current user (/Users/svoop/.bundle/config): true
gem.test
  Set for the current user (/Users/svoop/.bundle/config): "minitest"
gemfile
  Set via BUNDLE_GEMFILE: "/Users/svoop/Development/ofm/notam/gems.rb"
git.allow_insecure
  Set for the current user (/Users/svoop/.bundle/config): true

Gemfile

gems.rb

# frozen_string_literal: true

source "https://rubygems.org"

# Specify your gem's dependencies in notam.gemspec
gemspec

gem "rake", "~> 13.0"

gem "minitest", "~> 5.0"

gems.locked

PATH
  remote: .
  specs:
    notam (1.1.4)
      aixm (~> 1, >= 1.3.2)
      bigdecimal (~> 3)
      i18n (~> 1)

GEM
  remote: https://rubygems.org/
  specs:
    aixm (1.4.2)
      dry-inflector (~> 0)
      nokogiri (~> 1)
      sun (~> 1)
    bigdecimal (3.1.5)
    coderay (1.1.3)
    concurrent-ruby (1.2.2)
    debug (1.9.1)
      irb (~> 1.10)
      reline (>= 0.3.8)
    dry-inflector (0.3.0)
    ffi (1.16.3)
    formatador (1.1.0)
    guard (2.18.1)
      formatador (>= 0.2.4)
      listen (>= 2.7, < 4.0)
      lumberjack (>= 1.0.12, < 2.0)
      nenv (~> 0.1)
      notiffany (~> 0.0)
      pry (>= 0.13.0)
      shellany (~> 0.0)
      thor (>= 0.18.1)
    guard-compat (1.2.1)
    guard-minitest (2.4.6)
      guard-compat (~> 1.2)
      minitest (>= 3.0)
    i18n (1.14.1)
      concurrent-ruby (~> 1.0)
    io-console (0.7.1)
    irb (1.11.1)
      rdoc
      reline (>= 0.4.2)
    listen (3.8.0)
      rb-fsevent (~> 0.10, >= 0.10.3)
      rb-inotify (~> 0.9, >= 0.9.10)
    lumberjack (1.2.10)
    method_source (1.0.0)
    minitest (5.21.1)
    minitest-flash (0.1.0)
      minitest (>= 5)
    minitest-focus (1.4.0)
      minitest (>= 4, < 6)
    nenv (0.3.0)
    nokogiri (1.16.0-arm64-darwin)
      racc (~> 1.4)
    notiffany (0.1.3)
      nenv (~> 0.1)
      shellany (~> 0.0)
    pry (0.14.2)
      coderay (~> 1.1)
      method_source (~> 1.0)
    psych (5.1.2)
      stringio
    racc (1.7.3)
    rake (13.1.0)
    rb-fsevent (0.11.2)
    rb-inotify (0.10.1)
      ffi (~> 1.0)
    rdoc (6.6.2)
      psych (>= 4.0.0)
    reline (0.4.2)
      io-console (~> 0.5)
    shellany (0.0.1)
    stringio (3.1.0)
    sun (1.0.1)
    thor (1.3.0)
    yard (0.9.34)

PLATFORMS
  arm64-darwin-21
  arm64-darwin-22
  arm64-darwin-23

DEPENDENCIES
  debug
  guard
  guard-minitest
  minitest (~> 5.0)
  minitest-flash
  minitest-focus
  notam!
  rake (~> 13.0)
  yard

BUNDLED WITH
   2.5.3

Gemspecs

notam.gemspec

# frozen_string_literal: true

require_relative "lib/notam/version"

Gem::Specification.new do |spec|
  spec.name = "notam"
  spec.version = NOTAM::VERSION
  spec.summary     = 'Parser for NOTAM (Notice to Airmen) messages'
  spec.description = <<~END
    Parser for NOTAM (Notice to Airmen) messages in Ruby.
  END
  spec.authors     = ['Sven Schwyn']
  spec.email       = ['ruby@bitcetera.com']
  spec.homepage    = 'https://github.com/svoop/notam'
  spec.license     = 'MIT'

  spec.metadata = {
    'homepage_uri'      => spec.homepage,
    'changelog_uri'     => 'https://github.com/svoop/notam/blob/main/CHANGELOG.md',
    'source_code_uri'   => 'https://github.com/svoop/notam',
    'documentation_uri' => 'https://www.rubydoc.info/gems/notam',
    'bug_tracker_uri'   => 'https://github.com/svoop/notam/issues'
  }

  spec.files         = Dir['lib/**/*']
  spec.require_paths = %w(lib)

  spec.cert_chain  = ["certs/svoop.pem"]
  spec.signing_key = File.expand_path(ENV['GEM_SIGNING_KEY']) if ENV['GEM_SIGNING_KEY']

  spec.extra_rdoc_files = Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt']
  spec.rdoc_options    += [
    '--title', 'NOTAM Parser',
    '--main', 'README.md',
    '--line-numbers',
    '--inline-source',
    '--quiet'
  ]

  spec.required_ruby_version = '>= 3.0.0'

  spec.add_runtime_dependency 'aixm', '~> 1', '>= 1.3.2'
  spec.add_runtime_dependency 'bigdecimal', '~> 3'
  spec.add_runtime_dependency 'i18n', '~> 1'

  spec.add_development_dependency 'rake'
  spec.add_development_dependency 'debug'
  spec.add_development_dependency 'minitest'
  spec.add_development_dependency 'minitest-flash'
  spec.add_development_dependency 'minitest-focus'
  spec.add_development_dependency 'guard'
  spec.add_development_dependency 'guard-minitest'
  spec.add_development_dependency 'yard'
end
@svoop svoop added the Bundler label Jan 12, 2024
@svoop
Copy link
Contributor Author

svoop commented Jan 13, 2024

While trying to trace the exact source of the problem, I reinstalled Ruby 3.3.0 and the problem vanished.

@svoop svoop closed this as completed Jan 13, 2024
@kirillrdy
Copy link

I've ran into same issue

@lpar
Copy link

lpar commented May 6, 2024

Same issue with 3.3.1 and a trivial Gemfile

source "https://rubygems.org"
gem 'ipaddress'

Downgrading to Ruby 3.2.4 works.

@deivid-rodriguez
Copy link
Member

Please provide a way to reproduce the problem. That Gemfile works just fine for me.

@lpar
Copy link

lpar commented May 6, 2024

Hmm, not sure what to suggest. On a Mac it's:

brew install ruby@3.3
/opt/homebrew/opt/ruby@3.3/bin/bundle

with the above Gemfile in an otherwise empty directory.


Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
--- ERROR REPORT TEMPLATE -------------------------------------------------------

NoMethodError: undefined method `name' for nil
  /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:241:in `block in sorted'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:241:in `each'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:241:in `find'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:241:in `sorted'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/spec_set.rb:191:in `each'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/installer.rb:231:in `ensure_specs_are_compatible!'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/installer.rb:83:in `block in run'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/process_lock.rb:12:in `block in lock'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/process_lock.rb:9:in `open'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/process_lock.rb:9:in `lock'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/installer.rb:71:in `run'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/installer.rb:23:in `install'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/cli/install.rb:63:in `run'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:244:in `block in install'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/settings.rb:158:in `temporary'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:243:in `install'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:34:in `dispatch'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:28:in `start'
          /opt/homebrew/Cellar/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bundler-2.5.9/exe/bundle:28:in `block in <top (required)>'
          /opt/homebrew/lib/ruby/site_ruby/3.3.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
          /opt/homebrew/Cellar/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/bundler-2.5.9/exe/bundle:20:in `<top (required)>'
          /opt/homebrew/opt/ruby@3.3/bin/bundle:25:in `load'
          /opt/homebrew/opt/ruby@3.3/bin/bundle:25:in `<main>'

Environment

Bundler       2.5.6
  Platforms   ruby, arm64-darwin-23
Ruby          3.3.1p55 (2024-04-23 revision c56cd86388092faec079981f779f140717020d58) [arm64-darwin-23]
  Full Path   /opt/homebrew/opt/ruby/bin/ruby
  Config Dir  /opt/homebrew/Cellar/ruby/3.3.1/etc
RubyGems      3.5.6
  Gem Home    /opt/homebrew/lib/ruby/gems/3.3.0
  Gem Path    /Users/meta/.gem/ruby/3.3.0:/opt/homebrew/lib/ruby/gems/3.3.0:/opt/homebrew/Cellar/ruby/3.3.1/lib/ruby/gems/3.3.0
  User Home   /Users/meta
  User Path   /Users/meta/.gem/ruby/3.3.0
  Bin Dir     /opt/homebrew/lib/ruby/gems/3.3.0/bin
OpenSSL       
  Compiled    OpenSSL 3.3.0 9 Apr 2024
  Loaded      OpenSSL 3.3.0 9 Apr 2024
  Cert File   /opt/homebrew/etc/openssl@3/cert.pem
  Cert Dir    /opt/homebrew/etc/openssl@3/certs
Tools         
  Git         2.39.3 (Apple Git-146)
  RVM         not installed
  rbenv       not installed
  chruby      not installed
Gem.ruby      /opt/homebrew/opt/ruby/bin/ruby
bundle #!     /opt/homebrew/Cellar/ruby/3.3.1/bin/ruby

Bundler Build Metadata

Built At          2024-02-06
Git SHA           7ac045dcaa
Released Version  true

Gemfile

Gemfile

source "https://rubygems.org"
gem 'ipaddress'

Gemfile.lock

<No /Users/meta/Temporary/gemfile/Gemfile.lock found>

--- TEMPLATE END ----------------------------------------------------------------

Unfortunately, an unexpected error occurred, and Bundler cannot continue.

First, try this link to see if there are any existing issue reports for this error:
https://github.com/rubygems/rubygems/search?q=undefined+method+%60name%27+for+nil&type=Issues

If there aren't any reports for this error yet, please fill in the new issue form located at https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md, and copy and paste the report template above in there.

@deivid-rodriguez
Copy link
Member

Good to know you're using Ruby installed through Homebrew, that may be it. If you reinstall Ruby and/or Homebrew from scratch, does it consistently crash?

@svoop
Copy link
Contributor Author

svoop commented May 7, 2024

(As a side note: I rely on ruby-install to compile my Rubies and this happened to me as well.)

@svoop svoop reopened this May 7, 2024
@Tabby
Copy link

Tabby commented May 7, 2024

Was going to say similar, though I use rbenv's ruby-build plugin rather than ruby-install or homebrew

Environment

Bundler       2.5.10
  Platforms   ruby, x86_64-darwin-23
Ruby          3.3.1p55 (2024-04-23 revision c56cd86388092faec079981f779f140717020d58) [x86_64-darwin-23]
  Full Path   /Users/tabby/.rbenv/versions/3.3.1/bin/ruby
  Config Dir  /Users/tabby/.rbenv/versions/3.3.1/etc
RubyGems      3.5.10
  Gem Home    /Users/tabby/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0
  Gem Path    /Users/tabby/.gem/ruby/3.3.0:/Users/tabby/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0
  User Home   /Users/tabby
  User Path   /Users/tabby/.gem/ruby/3.3.0
  Bin Dir     /Users/tabby/.rbenv/versions/3.3.1/bin
OpenSSL
  Compiled    OpenSSL 3.3.0 9 Apr 2024
  Loaded      OpenSSL 3.3.0 9 Apr 2024
  Cert File   /usr/local/etc/openssl@3/cert.pem
  Cert Dir    /usr/local/etc/openssl@3/certs
Tools
  Git         2.45.0
  RVM         not installed
  rbenv       rbenv 1.2.0-87-ge8b7a27
  chruby      not installed

Bundler Build Metadata

Built At          2024-05-03
Git SHA           24cac00613
Released Version  true

@deivid-rodriguez
Copy link
Member

deivid-rodriguez commented May 7, 2024

Alright, then can someone please provide instructions to reproduce, using any version manager? Ideally setup a Dockerfile that can be run anywhere and shows the error.

@svoop
Copy link
Contributor Author

svoop commented May 7, 2024

@deivid-rodriguez I would really love to do so, but I was never able to reproduce the problem – which is why I closed the issue. Maybe someone else has more "luck".

@Tabby
Copy link

Tabby commented May 7, 2024

I'll give it a go, but I'm not that great with Docker. Might be easier to try and debug bundler itself

It's curious that all the errors seem to have occurred on Mac OS. I'll see if I can reproduce it on Linux with the same versions and config as if that doesn't error then it'll be tricky to make an image I think

@lpar
Copy link

lpar commented May 7, 2024

Works on macOS if I install Ruby using rbenv (with rbenv installed by Homebrew), so seems like it's a Homebrew issue, probably something to do with the binary build it installs. I wonder if it's reproducible using Homebrew on Linux?

@Tabby
Copy link

Tabby commented May 7, 2024

It's not Homebrew. As I mentioned above, I build ruby from source using ruby-build and I'm getting this issue

I have managed to reproduce it on Linux though by doing the following (using the Gemfile from this comment):

RUBY_CONFIGURE_OPTS="--enable-yjit" rbenv install 3.3.1
...
export RUBY_YJIT_ENABLE=1
bundle install

Running without the env var to enable YJIT completes successfully

I can't get it to complete successfully on Mac with YJIT disabled though so I don't know if that's the root cause

@deivid-rodriguez
Copy link
Member

Oh, that's super interesting. Then it may be a subtle change in behavior that YJIT is causing? So, just to confirm, if you install Ruby with YJIT, it reproduces every time. Otherwise, it never reproduces, correct?

@Tabby
Copy link

Tabby commented May 7, 2024

It certainly worked once before enabling YJIT, and failed after, though now it's failing every time on my linux machine even after disabling YJIT again

@Tabby
Copy link

Tabby commented May 7, 2024

Terminal output for the above
output.txt

@Tabby
Copy link

Tabby commented May 7, 2024

Ok, so it seems like it's not enough to just enable YJIT. I tried deleting the entire ruby install and reinstalling it again, and it worked fine. The exact steps that seem to reliably reproduce this are:

  • Ensure a "clean" install
    • rm -rf ~/.rbenv/versions/3.3.1
  • Install ruby 3.3.1 using rbenv
    • RUBY_CONFIGURE_OPTS="--enable-yjit" rbenv install 3.3.1
  • Update rubygems
    • gem update --system 3.5.10
  • Reinstall ruby 3.3.1 without removing the existing installation
    • RUBY_CONFIGURE_OPTS="--enable-yjit" rbenv install 3.3.1
  • Attempt to install gems
    • bundle install

I don't understand why but it seems to be the reinstalling ruby having already updated rubygems that might be the key to causing this error and YJIT may or may not be a red herring

@deivid-rodriguez
Copy link
Member

That's very helpful @Tabby, thanks. I will try to get this to reproduce for me using that information 👍.

@Tabby
Copy link

Tabby commented May 7, 2024

@deivid-rodriguez
Copy link
Member

I tried to reproduce using my ruby manager (asdf) but it won't let me "reinstall" Ruby. I'll try tomorrow using rbenv.

@deivid-rodriguez
Copy link
Member

It reproduced with the steps you pointed out @Tabby 🎉. I'll look into this!

@deivid-rodriguez
Copy link
Member

deivid-rodriguez commented May 9, 2024

Alright, so the problem was indeed reinstalling Ruby on top of a Ruby installation where RubyGems has been upgraded.

When upgrading RubyGems, the default version of Bundler is upgraded and the new copy is installed at site_dir directory. When reinstalling Ruby the site_dir directory with the upgraded copy of Bundler is not removed, but the default gemspec is reset back to the default (not upgraded) version of Bundler that comes with Ruby.

The mismatch between the gemspec version (2.5.9 in this case), and the upgraded version installed in site_dir (2.5.10 in this case) is causing the Bundler specification to be added to the Array of specifications used for resolution as nil, causing the crash.

I changed things in #7642 to detect the situation and try give a better error message.

@svoop
Copy link
Contributor Author

svoop commented May 9, 2024

Wow, @deivid-rodriguez, this sounds like the very edge of an edge case! Thanks for debugging this, your PR with a warning hinting on this problem (and the likely fix by fully zapping and reinstalling Ruby) will certainly prevent some hair from going grey.

@deivid-rodriguez
Copy link
Member

Indeed! Yeah, I got grey hair already so happy to go greyer myself in favor of people keeping their hair intact 😆.

I think we could probably fix this in ruby-core too by removing any pre-existing Bundler default installation if any. I'll give that a try!

@mloughran
Copy link

Thanks @deivid-rodriguez for getting to the bottom of this!

For anyone facing this and running homebrew ruby, I found that rm -rf /opt/homebrew/lib/ruby/site_ruby solved the problem.

@deivid-rodriguez
Copy link
Member

Indeed! Good hint for a workaround that does not involve reinstalling Ruby 👍.

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

Successfully merging a pull request may close this issue.

6 participants