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

Exception raised when upgraded to ruby 3.3.1 and deployed to Heroku #484

Closed
obromios opened this issue Apr 28, 2024 · 6 comments
Closed

Comments

@obromios
Copy link

obromios commented Apr 28, 2024

I made sure the issue is in bootsnap

When I commented bootstrap out of the Gemfile and commented out require "bootsnap/setup" from boot.rb then was able to deploy successfully.

Steps to reproduce

Upgrade to ruby 3.3.1 and bundle install, and commit Gemfile and Gemfile.lock
Then git push production master

Expected behavior

It should deploy to production.

Actual behavior

Saw following exception

remote: /tmp/codon/tmp/buildpacks/xxx/lib/language_pack/helpers/rake_runner.rb:100:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
remote: ensure you can run `$ bundle exec rake -P` against your app
remote: and using the production group of your Gemfile.
remote: /app/vendor/bundle/ruby/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30: warning: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/base64.rb was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec. Also contact author of activesupport-7.0.8.1 to add base64 into its gemspec.
remote: /app/vendor/bundle/ruby/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30: warning: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/bigdecimal.rb was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec. Also contact author of activesupport-7.0.8.1 to add bigdecimal into its gemspec.
remote: /app/vendor/bundle/ruby/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30: warning: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/mutex_m.rb was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add mutex_m to your Gemfile or gemspec. Also contact author of activesupport-7.0.8.1 to add mutex_m into its gemspec.
remote: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/bundled_gems.rb:72: warning: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/csv.rb was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add csv to your Gemfile or gemspec. Also contact author of blazer-2.6.5 to add csv into its gemspec.
remote: rake aborted!
remote: ArgumentError: comparison of String with nil failed (ArgumentError)
remote: 
remote:     msg = " #{RUBY_VERSION < SINCE[gem] ? "will no longer be" : "is not"} part of the default gems since Ruby #{SINCE[gem]}."
remote:                              ^^^^^^^^^^
remote: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/bundled_gems.rb:130:in `<'
remote: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/bundled_gems.rb:130:in `build_message'
remote: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/bundled_gems.rb:126:in `warning?'
remote: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/bundled_gems.rb:71:in `block (2 levels) in replace_require'
remote: /app/vendor/bundle/ruby/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'

System configuration

Bootsnap version:
1.18.3
Ruby version:
3.3.1
Rails version:
7.0.8.a

@byroot
Copy link
Contributor

byroot commented Apr 28, 2024

This is a Ruby 3.3.1 bug, see: https://bugs.ruby-lang.org/issues/20450

To work around it you can add mutex_m to your Gemfile.

@marknuzz
Copy link

marknuzz commented May 1, 2024

This is a Ruby 3.3.1 bug, see: https://bugs.ruby-lang.org/issues/20450

To work around it you can add mutex_m to your Gemfile.

@byroot Unfortunately adding mutex_m to the gemfile did not resolve this for me. Do you have some additional context or advice that could help work around this?

@marknuzz
Copy link

marknuzz commented May 1, 2024

For anyone else who needs this, here's what I did to fix (credit to eugeneius) ruby/ruby#10619 (comment):

create lib/monkey_patches/rubygems_bundled_gems_warning.rb

# frozen_string_literal: true
# typed: ignore
# rubocop:disable all
# :nocov:

# Context: Bootsnap doesn't work with Ruby 3.3.1
# https://github.com/Shopify/bootsnap/issues/484
# https://github.com/ruby/ruby/pull/10619
# https://bugs.ruby-lang.org/issues/20450
# https://github.com/ruby/ruby/pull/10619#issuecomment-2075896240

mod = Gem.send(:remove_const, :BUNDLED_GEMS).dup
Gem::BUNDLED_GEMS = mod
def mod.warning?(name, specs: nil)
  # name can be a feature name or a file path with String or Pathname
  feature = File.path(name)
  # bootsnap expands `require "csv"` to `require "#{LIBDIR}/csv.rb"`,
  # and `require "syslog"` to `require "#{ARCHDIR}/syslog.so"`.
  name = feature.delete_prefix(Gem::BUNDLED_GEMS::ARCHDIR)
  name.delete_prefix!(Gem::BUNDLED_GEMS::LIBDIR)
  name.tr!("/", "-")
  name.sub!(Gem::BUNDLED_GEMS::LIBEXT, "")
  return if specs.include?(name)
  _t, path = $:.resolve_feature_path(feature)
  if gem = find_gem(path)
    return if specs.include?(gem)
    caller = caller_locations(3, 3)&.find {|c| c&.absolute_path}
    return if find_gem(caller&.absolute_path)
  elsif Gem::BUNDLED_GEMS::SINCE[name]
    gem = true
  else
    return
  end

  return if Gem::BUNDLED_GEMS::WARNED[name]
  Gem::BUNDLED_GEMS::WARNED[name] = true
  if gem == true
    gem = name
    "#{feature} was loaded from the standard library, but"
  elsif gem
    return if Gem::BUNDLED_GEMS::WARNED[gem]
    Gem::BUNDLED_GEMS::WARNED[gem] = true
    "#{feature} is found in #{gem}, which"
  else
    return
  end + build_message(gem)
end

At the start of application.rb:
require_relative "../lib/monkey_patches/rubygems_bundled_gems_warning"

@casperisfine
Copy link
Contributor

Unfortunately adding mutex_m to the gemfile did not resolve this for me. Do you have some additional context or advice that could help work around this?

After reformating your issue, it now seems clear mutex_m is just the first of three issues:

remote: /app/vendor/bundle/ruby/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30: warning: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/base64.rb was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec. Also contact author of activesupport-7.0.8.1 to add base64 into its gemspec.
remote: /app/vendor/bundle/ruby/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30: warning: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/bigdecimal.rb was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec. Also contact author of activesupport-7.0.8.1 to add bigdecimal into its gemspec.
remote: /app/vendor/bundle/ruby/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30: warning: /app/vendor/ruby-3.3.1/lib/ruby/3.3.0/mutex_m.rb was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add mutex_m to your Gemfile or gemspec. Also contact author of activesupport-7.0.8.1 to add mutex_m into its gemspec.

So you not only need mutex_m, but also bigdecimal and base64. I'll see about backporting this fix to Active Support 7.0 branch.

@casperisfine
Copy link
Contributor

Actually that was done a while ago already, just not released yet: rails/rails#50546

@obromios
Copy link
Author

obromios commented May 2, 2024

I tried deploying with
gem 'base64'
gem 'bigdecimal'
gem 'mutex_m'
and still had the same problem.

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

No branches or pull requests

4 participants