getsentry / sentry-ruby

Sentry SDK for Ruby
https://sentry.io/for/ruby
MIT License
927 stars 486 forks source link

Sentry-rails 5.18.0 is incompatible with bundler standalone #2329

Closed aaronjensen closed 1 month ago

aaronjensen commented 1 month ago

Issue Description

https://github.com/getsentry/sentry-ruby/commit/7b00b250968164cb4bb6ee7ac4a777dc2e868252 introduced invocations of Gem::Specification.find_by_name, which doesn't work when using bundler standalone. This means that this release will cause production issues for people that use bundler standalone.

/Users/my-username/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/rubygems/dependency.rb:313:in `to_specs': Could not find 'sentry-ruby' (>= 0) among 333 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/my-username/.gem/ruby/3.3.0:/Users/my-username/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0' , execute `gem env` for more information
        from /Users/my-username/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/rubygems/dependency.rb:325:in `to_spec'
        from /Users/my-username/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/rubygems/specification.rb:1023:in `find_by_name'
        from /Users/my-username/Source/my-project/gems/ruby/3.3.0/gems/sentry-rails-5.18.0/lib/sentry/rails/tracing/active_record_subscriber.rb:16:in `<class:ActiveRecordSubscriber>'
        from /Users/my-username/Source/my-project/gems/ruby/3.3.0/gems/sentry-rails-5.18.0/lib/sentry/rails/tracing/active_record_subscriber.rb:6:in `<module:Tracing>'
        from /Users/my-username/Source/my-project/gems/ruby/3.3.0/gems/sentry-rails-5.18.0/lib/sentry/rails/tracing/active_record_subscriber.rb:5:in `<module:Rails>'
        from /Users/my-username/Source/my-project/gems/ruby/3.3.0/gems/sentry-rails-5.18.0/lib/sentry/rails/tracing/active_record_subscriber.rb:4:in `<module:Sentry>'
        from /Users/my-username/Source/my-project/gems/ruby/3.3.0/gems/sentry-rails-5.18.0/lib/sentry/rails/tracing/active_record_subscriber.rb:3:in `<main>'
        from <internal:/Users/my-username/.asdf/installs/ruby/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:37:in `require' 

Reproduction Steps

No time right now, having to deal with the issues created by this new release.

Expected Behavior

It doesn't crash when using bundler standalone

Actual Behavior

It crashes

Ruby Version

3.3.1

SDK Version

5.18.0

Integration and Its Version

No response

Sentry Config

No response

aaronjensen commented 1 month ago

The comment on the offending lines says:

# Need to be specific down to the lib path so queries generated in specs don't get ignored

What does this mean? Is this referring to specs in this project? Does this mean that explicit code was added to the applicative library work around problems in this projects tests? It seems like the tests should be able to control what they need to control in order to work and this code shouldn't need to resort to something so uncommon. I've seen projects use Gem::Specification to figure out if a gem is present (Rails does this), but I've never seen anything actually get the source location. That seems like a bridge too far.

sl0thentr0py commented 1 month ago

ok this is caused by the changes in #2313, please pin to an older version for now till I release a fix. cc @st0012

sl0thentr0py commented 1 month ago

@st0012 I agree with the comment above that if we're using Gem::Specification only for tests, that's unjustified. Why not simply match on sentry-ruby/sentry-rails as a simple string match in the backtrace_cleaner?

st0012 commented 1 month ago

Sorry for the trouble, I wasn't aware that invoking Gem::Specification would cause issues in some setup. In the projects I worked with it's all been available so I wanted to get the most accurate source result with it. I'll open a PR to address it.

sl0thentr0py commented 1 month ago

released in 5.18.1