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

Update activesupport #394

Merged
merged 2 commits into from
Jan 13, 2025
Merged

Update activesupport #394

merged 2 commits into from
Jan 13, 2025

Conversation

etiennebarrie
Copy link
Member

After merging #392, CI failed on ruby-head because logger is no longer part of the standard library.

It could be added to Bundler, but instead I upgraded activesupport so that we are testing with Active Support 8.0. But it's incompatible with Ruby 3.1 so I also tweaked the CI scripts to use an older version there.

@etiennebarrie etiennebarrie requested a review from a team January 13, 2025 15:30
@etiennebarrie etiennebarrie merged commit 1cba325 into main Jan 13, 2025
13 checks passed
@etiennebarrie etiennebarrie deleted the update-activesupport branch January 13, 2025 15:33
@mvz
Copy link
Contributor

mvz commented Jan 20, 2025

Given this solution, what is your advice on how to run erb_lint in the context of a bundle with rails 7.0 and concurrent-ruby 1.3.5?

@etiennebarrie
Copy link
Member Author

If you add logger to your Gemfile, then concurrent-ruby will be able to find it in your bundle.

@mvz
Copy link
Contributor

mvz commented Jan 20, 2025

It's not concurrent-ruby that needs to find it, it's activesupport. Even when logger is in the bundle, there's no code that requires it when running bundle exec erb_lint --lint-all. I still get uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError):

/home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support/logger_thread_safe_level.rb:12:in `<module:LoggerThreadSafeLevel>': uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)

    Logger::Severity.constants.each do |severity|
    ^^^^^^
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support/logger_thread_safe_level.rb:9:in `<module:ActiveSupport>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support/logger_thread_safe_level.rb:8:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support/logger_silence.rb:5:in `require'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support/logger_silence.rb:5:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support/logger.rb:3:in `require'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support/logger.rb:3:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support.rb:29:in `require'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.7/lib/active_support.rb:29:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/erb_lint-0.8.0/lib/erb_lint/linter_config.rb:3:in `require'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/erb_lint-0.8.0/lib/erb_lint/linter_config.rb:3:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/erb_lint-0.8.0/lib/erb_lint/all.rb:10:in `require'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/erb_lint-0.8.0/lib/erb_lint/all.rb:10:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/erb_lint-0.8.0/lib/erb_lint/cli.rb:3:in `require'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/erb_lint-0.8.0/lib/erb_lint/cli.rb:3:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/erb_lint-0.8.0/exe/erb_lint:7:in `require'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/erb_lint-0.8.0/exe/erb_lint:7:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/bin/erb_lint:25:in `load'
	from /home/matijs/.rbenv/versions/3.1.4/bin/erb_lint:25:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/cli/exec.rb:58:in `load'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/cli/exec.rb:23:in `run'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/cli.rb:451:in `exec'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/cli.rb:34:in `dispatch'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/cli.rb:28:in `start'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/exe/bundle:28:in `block in <top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /home/matijs/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.9/exe/bundle:20:in `<top (required)>'
	from /home/matijs/.rbenv/versions/3.1.4/bin/bundle:25:in `load'
	from /home/matijs/.rbenv/versions/3.1.4/bin/bundle:25:in `<main>'

@etiennebarrie
Copy link
Member Author

Oh right, the solution for now is to lock concurrent-ruby to 1.3.4 or to run 7-0-stable: rails/rails#54260

FWIW the changes from this PR here didn't change the gem at all, just the development environment for the gem. To fix this, we could either depend on activesupport ~> 7.1.0 or on logger, but neither is a good solution, because this is not really an issue with erb_lint. We don't use logger directly, and forcing everyone to upgrade Rails/Active Support is not our job.

It's just that Active Support 7.0 is broken with concurrent-ruby 1.3.5:

$ gem install activesupport -v '~> 7.0.0' &>/dev/null
$ gem install concurrent-ruby &>/dev/null
$ ruby -e 'gem "activesupport", "~> 7.0.0"; require "active_support"'
/Users/etienne/.gem/ruby/3.2.2/gems/activesupport-7.0.8.7/lib/active_support/logger_thread_safe_level.rb:12:in `<module:LoggerThreadSafeLevel>': uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)

    Logger::Severity.constants.each do |severity|
          ^^^^^^^^^^
	from /Users/etienne/.gem/ruby/3.2.2/gems/activesupport-7.0.8.7/lib/active_support/logger_thread_safe_level.rb:9:in `<module:ActiveSupport>'
	from /Users/etienne/.gem/ruby/3.2.2/gems/activesupport-7.0.8.7/lib/active_support/logger_thread_safe_level.rb:8:in `<top (required)>'
	from <internal:/opt/rubies/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
	from <internal:/opt/rubies/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
	from /Users/etienne/.gem/ruby/3.2.2/gems/activesupport-7.0.8.7/lib/active_support/logger_silence.rb:5:in `<top (required)>'
	from <internal:/opt/rubies/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
	from <internal:/opt/rubies/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
	from /Users/etienne/.gem/ruby/3.2.2/gems/activesupport-7.0.8.7/lib/active_support/logger.rb:3:in `<top (required)>'
	from <internal:/opt/rubies/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
	from <internal:/opt/rubies/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
	from /Users/etienne/.gem/ruby/3.2.2/gems/activesupport-7.0.8.7/lib/active_support.rb:29:in `<top (required)>'
	from <internal:/opt/rubies/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
	from <internal:/opt/rubies/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
	from -e:1:in `<main>'

For unsupported series, bug fixes may coincidentally land in a stable branch, but won't be released in an official version. It is recommended to point your application at the stable branch using Git for unsupported versions.
https://guides.rubyonrails.org/maintenance_policy.html#bug-fixes

@etiennebarrie
Copy link
Member Author

Oh I forgot one workaround you might be able to use:

$ bundle binstub erb_lint
$ ruby -pi -e 'print %(require "logger"\n) if /Gem\.bin_path/' -- bin/erb_lint
$ # replace all occurrences of `bundle exec erb_lint` with `bin/erb_lint`

Not great, but until you can upgrade, that's probably the simplest.

@mvz
Copy link
Contributor

mvz commented Jan 21, 2025

Thanks @etiennebarrie, I will try that workaround.

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

Successfully merging this pull request may close these issues.

3 participants