Ruby 3.3 (rc1) with Rails 6.1/7.0/7.1 with bootsnap fails

Hello I’m investigating at using Ruby 3.3 but it fails at boot due to bootsnap. I got this error:

❯ rails c
/Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:120:in `<': comparison of String with nil failed (ArgumentError)

    msg = " #{RUBY_VERSION < SINCE[gem] ? "will no longer be" : "is not"} part of the default gems since Ruby #{SINCE[gem]}."
                             ^^^^^^^^^^
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:120:in `build_message'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:116:in `warning?'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:65:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/activesupport-7.1.2/lib/active_support/notifications/fanout.rb:3:in `<main>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/activesupport-7.1.2/lib/active_support/notifications.rb:4:in `<main>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/activesupport-7.1.2/lib/active_support/deprecation/behaviors.rb:3:in `<main>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/activesupport-7.1.2/lib/active_support/deprecation.rb:45:in `<class:Deprecation>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/activesupport-7.1.2/lib/active_support/deprecation.rb:35:in `<module:ActiveSupport>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/activesupport-7.1.2/lib/active_support/deprecation.rb:5:in `<main>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/application.rb:8:in `<main>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails.rb:15:in `<main>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/all.rb:5:in `<main>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /Users/thomas/projects/hotwire_2023-12/config/application.rb:3:in `<main>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/command/actions.rb:15:in `require_application!'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/command/environment_argument.rb:31:in `require_application!'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/command/actions.rb:19:in `boot_application!'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/commands/console/console_command.rb:105:in `perform'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/command/base.rb:178:in `invoke_command'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/command/base.rb:73:in `perform'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/command.rb:71:in `block in invoke'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/command.rb:149:in `with_argv'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/command.rb:69:in `invoke'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/railties-7.1.2/lib/rails/commands.rb:18:in `<main>'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/3.3.0+0/bundled_gems.rb:68:in `block (2 levels) in replace_require'
        from /Users/thomas/.rbenv/versions/3.3.0-rc1/lib/ruby/gems/3.3.0+0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from bin/rails:4:in `<main>'

When I comment out the require "bootsnap/setup" from the boot.rb file, there is no issue. It fails here: ruby/lib/bundled_gems.rb at master · ruby/ruby · GitHub

  • Without bootsnap the variable name are like: net-smtp.
  • With bootsnap the variable name are like: -Users-thomas-.rbenv-versions-3.3.0-rc1-lib-ruby-3.3.0+0-mutex_m

It is a filepath that has been dash-ed here: ruby/lib/bundled_gems.rb at master · ruby/ruby · GitHub

I use a generated Rails 7.1.2 app with a single autogenerated scaffold on MacOS arm64. I have the same issue on non-hello-world project with Rails 6.1, 7.0 or 7.1.

Any idea?

1 Like

The Ruby master branch has handled this, so it should no longer be a problem in the 3.3.0.

Bug #20060: bundled_gems.rb is not working with Bootsnap - Ruby master - Ruby Issue Tracking System

Thank you. I was not aware. ありがとうございます。じゃ、25日を待ってます。

Did you manage to make it work with Rails edge, Thomas ? It didn’t work on my end…

It’s an issue in Ruby itself. Rails edge won’t be able to solve that problem. You can:

  • use an earlier version: 3.3.0-preview3 works well
  • compile Ruby from the master branch
  • wait Christmas for the final 3.3.0 release
  • disable bootsnap until 3.3.0 release

I’m getting this error now with upgrading to Ruby 3.3.1. Is there a solution to this yet?

/Users/me/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:130:in `<': comparison of String with nil failed (ArgumentError)

    msg = " #{RUBY_VERSION < SINCE[gem] ? "will no longer be" : "is not"} part of the default gems since Ruby #{SINCE[gem]}."
                             ^^^^^^^^^^
	from /Users/me/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:130:in `build_message'
	from /Users/me/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:126:in `warning?'

There’s an issue between Ruby and Bootsnap.

Rerun your command with DISABLE_BOOTSNAP=1 in front with Ruby 3.3.

Some gems will moved from Ruby core to a bundled gems (that needs to be in the Gemfile). There’s a list of all those gems here: https://www.ruby-lang.org/en/news/2023/12/25/ruby-3-3-0-released/

The list of future bundled gems:

abbrev
base64
bigdecimal
csv
drb
getoptlong
mutex_m
nkf
observer
racc
resolv-replace
rinda
syslog