zombocom / derailed_benchmarks

Go faster, off the Rails - Benchmarks for your whole Rails app
2.98k stars 144 forks source link

Compatibility in ruby >=3.2 ? #233

Open Jaco-Pretorius opened 11 months ago

Jaco-Pretorius commented 11 months ago

I am having issues with running derailed against a Rails app with Ruby 3.2.2. The issue is rather obscure, but I'll put the stacktrace here

/Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/dead_end-1.1.6/lib/dead_end/auto.rb:30:in `require': cannot load such file -- /Users/my-user-name/src/ext/save-history.rb (LoadError)
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/dead_end-1.1.6/lib/dead_end/auto.rb:30:in `require_relative'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/extend-command.rb:368:in `save_history='
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/context.rb:137:in `initialize'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:473:in `new'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:473:in `initialize'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:419:in `new'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:419:in `start'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/commands/console/console_command.rb:70:in `start'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/commands/console/console_command.rb:19:in `start'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/commands/console/console_command.rb:102:in `perform'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/command/base.rb:87:in `perform'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/command.rb:48:in `invoke'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

I suspect this is because the dead_end gem - which is the syntax_suggest repo - has been integrated with Ruby 3.2. At the very least it's not clear to me what is expected to happen if you include that gem while running Ruby 3.2 or later. There is an issue against the syntax_suggest repo which seems to indicate that you no longer need to include the gem but it doesn't say what will happen when you do. The stacktrace above does point to some of the require_relative overrides going on in that gem.

schneems commented 11 months ago

This would only ever fire if you’ve got a syntax error or are trying to load a file that doesn’t exist.

if someone wants to remove dead-end or upgrade it to syntax_suggest I would accept the change.

s01ipsist commented 6 months ago

(possibly) addresssed by https://github.com/zombocom/derailed_benchmarks/pull/228 which replaces dead_end with syntax_suggest which is the renamed library https://github.com/ruby/syntax_suggest/blob/main/CHANGELOG.md#100-library-renamed-to-syntax_suggest-

pcai commented 1 month ago

Hi @Jaco-Pretorius as @schneems mentioned, this doesnt appear to be a dead_end/syntax_suggest issue and the main branch now has coverage for ruby 3.2 specifically. Since #230 already tracks the dead_end migration work I'll close this for now. Please reopen with repro steps against the latest derailed if you still believe there's a bug here. Thanks!

fkoessler commented 3 weeks ago

For the record, I am experiencing a similar issue with Ruby 3.1.3 and derailed_benchmark 2.2.1

/home/username/.rvm/gems/ruby-3.1.3@project/gems/derailed_benchmarks-2.2.1/lib/derailed_benchmarks.rb:7:in `require': cannot load such file -- syntax_suggest (LoadError)
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/derailed_benchmarks-2.2.1/lib/derailed_benchmarks.rb:7:in `<top (required)>'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:60:in `require'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:55:in `each'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:55:in `block in require'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:44:in `each'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:44:in `require'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler.rb:195:in `require'
    from /home/username/Code/project/project/config/application.rb:8:in `<top (required)>'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/commands/server/server_command.rb:137:in `require'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/commands/server/server_command.rb:137:in `block in perform'
    from <internal:kernel>:90:in `tap'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/commands/server/server_command.rb:134:in `perform'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/command/base.rb:87:in `perform'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/command.rb:48:in `invoke'
    from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
pcai commented 3 weeks ago

Can you provide a minimal repro please? Your output suggests that syntax_suggest is missing from bundle path but its not clear what command you’re running or how things are set up

unRARed commented 2 weeks ago

For the record, I am experiencing a similar issue with Ruby 3.1.3 and derailed_benchmark 2.2.1

/home/username/.rvm/gems/ruby-3.1.3@project/gems/derailed_benchmarks-2.2.1/lib/derailed_benchmarks.rb:7:in `require': cannot load such file -- syntax_suggest (LoadError)
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/derailed_benchmarks-2.2.1/lib/derailed_benchmarks.rb:7:in `<top (required)>'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:60:in `require'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:55:in `each'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:55:in `block in require'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:44:in `each'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler/runtime.rb:44:in `require'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/bundler-2.4.7/lib/bundler.rb:195:in `require'
  from /home/username/Code/project/project/config/application.rb:8:in `<top (required)>'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/commands/server/server_command.rb:137:in `require'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/commands/server/server_command.rb:137:in `block in perform'
  from <internal:kernel>:90:in `tap'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/commands/server/server_command.rb:134:in `perform'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/command/base.rb:87:in `perform'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/command.rb:48:in `invoke'
  from /home/username/.rvm/gems/ruby-3.1.3@project/gems/railties-7.0.8.6/lib/rails/commands.rb:18:in `<top (required)>'
  from bin/rails:4:in `require'
  from bin/rails:4:in `<main>'

I just ran into the same error in 3.1.2. I'm guessing the syntax_suggest gem is missing from the derailed gemspec? Simply adding the gem to my Gemfile fixed it:

group :development do
 ...
  gem "syntax_suggest" # <-- added this
  gem "derailed_benchmarks"
  gem "stackprof"
  ...
end
schneems commented 1 week ago

I think an issue is the conditional in the gemspec. If you look at the dependencies on rubygems it doesn't list out syntax_suggest https://rubygems.org/gems/derailed_benchmarks/versions/2.2.1. It works with Ruby 3.2+ on CI because that gem exists

pcai commented 1 week ago

The intent of the conditional was to avoid declaring syntax_suggest for ruby versions where it is already a default gem, but if there's no harm in declaring it unconditionally -- I'll just make that change? wdyt @schneems

schneems commented 1 week ago

Sounds good to me

Richard Schneeman https://howtoopensource.dev https://www.schneems.com he/him

On Sat, Nov 16, 2024 at 2:20 PM Peter Cai @.***> wrote:

The intent of the conditional was to avoid declaring syntax_suggest for ruby versions where it is already a default gem, but if there's no harm in declaring it unconditionally -- I'll just make that change? wdyt @schneems https://github.com/schneems

— Reply to this email directly, view it on GitHub https://github.com/zombocom/derailed_benchmarks/issues/233#issuecomment-2480785550, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOSYAF2NEABWUUX7TE5NL2A6SHHAVCNFSM6AAAAABAX6VFM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBQG44DKNJVGA . You are receiving this because you were mentioned.Message ID: @.***>