Sentry-ruby: Sentry.init problem after upgrade sentry rails to version 4.3.3 (the dependency using railties)

Created on 29 Mar 2021  路  9Comments  路  Source: getsentry/sentry-ruby

Describe the bug
This bug happens after I update Gemfile especially sentry-rails from version 4.3.2 to 4.3.3, there is an error

``NoMethodError: undefined methoddebug' for nil:NilClass
Did you mean? debugger

**To Reproduce**
1. Remove Gemfile.lock
2. execute `Bundle`
3. or you can execute `Bundle update`

**Expected behavior**
Sentry should not cause an error

**Actual behavior**

Failure/Error: require File.expand_path("../config/environment", __dir__)

NoMethodError:
undefined method `debug' for nil:NilClass
Did you mean? debugger
```
Environment

  • Ruby Version: 2.6.6
  • sentry-ruby: 4.2
  • sentry-rails: 4.3.3

    • Rails : 6.0.3

bug sentry-ruby

Most helpful comment

this looks identical to https://github.com/getsentry/sentry-ruby/issues/1365

can you move your Sentry configuration into its own initializer file? config/initializers/sentry.rb

All 9 comments

@helmiItsavirus you should also upgrade your sentry-ruby to 4.3.* versions. can you upgrade it as well?

@st0012

This is my Gemfile.lock

  remote: https://github.com/jejacks0n/apitome.git
  revision: 27487b66a57c3a4f33851b78b0ce09839fc278ef
  specs:
    apitome (0.3.0)
      kramdown
      railties

GIT
  remote: https://github.com/ukazap/jsonapi.rb.git
  revision: 431e75efc23b50994b15077f80e9d2d3198eadf4
  specs:
    jsonapi.rb (1.6.0)
      jsonapi-serializer (~> 2.0)
      rack
      ransack

GEM
  remote: https://rubygems.org/
  specs:
    action_policy (0.4.4)
    actioncable (6.0.3.6)
      actionpack (= 6.0.3.6)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailbox (6.0.3.6)
      actionpack (= 6.0.3.6)
      activejob (= 6.0.3.6)
      activerecord (= 6.0.3.6)
      activestorage (= 6.0.3.6)
      activesupport (= 6.0.3.6)
      mail (>= 2.7.1)
    actionmailer (6.0.3.6)
      actionpack (= 6.0.3.6)
      actionview (= 6.0.3.6)
      activejob (= 6.0.3.6)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (6.0.3.6)
      actionview (= 6.0.3.6)
      activesupport (= 6.0.3.6)
      rack (~> 2.0, >= 2.0.8)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.2.0)
    actiontext (6.0.3.6)
      actionpack (= 6.0.3.6)
      activerecord (= 6.0.3.6)
      activestorage (= 6.0.3.6)
      activesupport (= 6.0.3.6)
      nokogiri (>= 1.8.5)
    actionview (6.0.3.6)
      activesupport (= 6.0.3.6)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.1, >= 1.2.0)
    activejob (6.0.3.6)
      activesupport (= 6.0.3.6)
      globalid (>= 0.3.6)
    activemodel (6.0.3.6)
      activesupport (= 6.0.3.6)
    activerecord (6.0.3.6)
      activemodel (= 6.0.3.6)
      activesupport (= 6.0.3.6)
    activerecord-nulldb-adapter (0.4.0)
      activerecord (>= 2.0.0)
    activestorage (6.0.3.6)
      actionpack (= 6.0.3.6)
      activejob (= 6.0.3.6)
      activerecord (= 6.0.3.6)
      marcel (~> 1.0.0)
    activesupport (6.0.3.6)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
      zeitwerk (~> 2.2, >= 2.2.2)
    addressable (2.7.0)
      public_suffix (>= 2.0.2, < 5.0)
    administrate (0.14.0)
      actionpack (>= 4.2)
      actionview (>= 4.2)
      activerecord (>= 4.2)
      autoprefixer-rails (>= 6.0)
      datetime_picker_rails (~> 0.0.7)
      jquery-rails (>= 4.0)
      kaminari (>= 1.0)
      momentjs-rails (~> 2.8)
      sassc-rails (~> 2.1)
      selectize-rails (~> 0.6)
    aliyunsdkcore (0.0.17)
      activesupport (>= 3.0.0)
      faraday (>= 0.15.4)
    ast (2.4.2)
    autoprefixer-rails (10.2.4.0)
      execjs
    aws-eventstream (1.1.1)
    aws-partitions (1.436.0)
    aws-sdk-core (3.113.0)
      aws-eventstream (~> 1, >= 1.0.2)
      aws-partitions (~> 1, >= 1.239.0)
      aws-sigv4 (~> 1.1)
      jmespath (~> 1.0)
    aws-sdk-kms (1.43.0)
      aws-sdk-core (~> 3, >= 3.112.0)
      aws-sigv4 (~> 1.1)
    aws-sdk-s3 (1.93.0)
      aws-sdk-core (~> 3, >= 3.112.0)
      aws-sdk-kms (~> 1)
      aws-sigv4 (~> 1.1)
    aws-sigv4 (1.2.3)
      aws-eventstream (~> 1, >= 1.0.2)
    bcrypt (3.1.16)
    bindex (0.8.1)
    bootsnap (1.7.3)
      msgpack (~> 1.0)
    builder (3.2.4)
    bullet (6.1.4)
      activesupport (>= 3.0.0)
      uniform_notifier (~> 1.11)
    byebug (11.1.3)
    code_analyzer (0.5.2)
      sexp_processor
    concurrent-ruby (1.1.8)
    content_disposition (1.0.0)
    countries (3.1.0)
      i18n_data (~> 0.11.0)
      sixarm_ruby_unaccent (~> 1.1)
      unicode_utils (~> 1.4)
    crass (1.0.6)
    database_cleaner (1.99.0)
    database_cleaner-active_record (1.99.0)
      activerecord
      database_cleaner (~> 1.99.0)
    datetime_picker_rails (0.0.7)
      momentjs-rails (>= 2.8.1)
    devise (4.7.3)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0)
      responders
      warden (~> 1.2.3)
    devise-i18n (1.9.3)
      devise (>= 4.7.1)
    devise-jwt (0.8.1)
      devise (~> 4.0)
      warden-jwt_auth (~> 0.5)
    diff-lcs (1.4.4)
    dotenv (2.7.6)
    dotenv-rails (2.7.6)
      dotenv (= 2.7.6)
      railties (>= 3.2)
    down (5.2.0)
      addressable (~> 2.5)
    dry-auto_inject (0.7.0)
      dry-container (>= 0.3.4)
    dry-configurable (0.12.1)
      concurrent-ruby (~> 1.0)
      dry-core (~> 0.5, >= 0.5.0)
    dry-container (0.7.2)
      concurrent-ruby (~> 1.0)
      dry-configurable (~> 0.1, >= 0.1.3)
    dry-core (0.5.0)
      concurrent-ruby (~> 1.0)
    erubi (1.10.0)
    erubis (2.7.0)
    execjs (2.7.0)
    factory_bot (6.1.0)
      activesupport (>= 5.0.0)
    factory_bot_rails (6.1.0)
      factory_bot (~> 6.1.0)
      railties (>= 5.0.0)
    faker (2.17.0)
      i18n (>= 1.6, < 2)
    faraday (1.3.0)
      faraday-net_http (~> 1.0)
      multipart-post (>= 1.2, < 3)
      ruby2_keywords
    faraday-net_http (1.0.1)
    ffi (1.15.0)
    globalid (0.4.2)
      activesupport (>= 4.2.0)
    i18n (1.8.9)
      concurrent-ruby (~> 1.0)
    i18n_data (0.11.0)
    image_processing (1.12.1)
      mini_magick (>= 4.9.5, < 5)
      ruby-vips (>= 2.0.17, < 3)
    jmespath (1.4.0)
    jquery-rails (4.4.0)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (2.5.1)
    json_translate (4.0.0)
      activerecord (>= 4.2.0)
    jsonapi-serializer (2.2.0)
      activesupport (>= 4.2)
    jwt (2.2.2)
    kaminari (1.2.1)
      activesupport (>= 4.1.0)
      kaminari-actionview (= 1.2.1)
      kaminari-activerecord (= 1.2.1)
      kaminari-core (= 1.2.1)
    kaminari-actionview (1.2.1)
      actionview
      kaminari-core (= 1.2.1)
    kaminari-activerecord (1.2.1)
      activerecord
      kaminari-core (= 1.2.1)
    kaminari-core (1.2.1)
    kramdown (2.3.1)
      rexml
    language_filter (0.3.01)
    launchy (2.5.0)
      addressable (~> 2.7)
    letter_opener (1.7.0)
      launchy (~> 2.2)
    letter_opener_web (1.4.0)
      actionmailer (>= 3.2)
      letter_opener (~> 1.0)
      railties (>= 3.2)
    listen (3.5.0)
      rb-fsevent (~> 0.10, >= 0.10.3)
      rb-inotify (~> 0.9, >= 0.9.10)
    loofah (2.9.0)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.1)
      mini_mime (>= 0.1.1)
    marcel (1.0.0)
    method_source (1.0.0)
    mini_magick (4.11.0)
    mini_mime (1.0.3)
    minitest (5.14.4)
    momentjs-rails (2.20.1)
      railties (>= 3.1)
    msgpack (1.4.2)
    multipart-post (2.1.1)
    mustache (1.1.1)
    nexmo (7.2.1)
      nexmo-jwt (~> 0.1.1)
      sorbet-runtime (~> 0.5)
      zeitwerk (~> 2, >= 2.2)
    nexmo-jwt (0.1.2)
      jwt (~> 2)
    nio4r (2.5.7)
    nokogiri (1.11.2-x86_64-linux)
      racc (~> 1.4)
    orm_adapter (0.5.0)
    parallel (1.20.1)
    parser (3.0.0.0)
      ast (~> 2.4.1)
    pg (1.2.3)
    pg_search (2.3.5)
      activerecord (>= 5.2)
      activesupport (>= 5.2)
    phonelib (0.6.49)
    public_suffix (4.0.6)
    puma (4.3.7)
      nio4r (~> 2.0)
    racc (1.5.2)
    rack (2.2.3)
    rack-cors (1.1.1)
      rack (>= 2.0.0)
    rack-proxy (0.6.5)
      rack
    rack-test (1.1.0)
      rack (>= 1.0, < 3)
    rack-throttle (0.7.0)
      bundler (>= 1.0.0)
      rack (>= 1.0.0)
    rails (6.0.3.6)
      actioncable (= 6.0.3.6)
      actionmailbox (= 6.0.3.6)
      actionmailer (= 6.0.3.6)
      actionpack (= 6.0.3.6)
      actiontext (= 6.0.3.6)
      actionview (= 6.0.3.6)
      activejob (= 6.0.3.6)
      activemodel (= 6.0.3.6)
      activerecord (= 6.0.3.6)
      activestorage (= 6.0.3.6)
      activesupport (= 6.0.3.6)
      bundler (>= 1.3.0)
      railties (= 6.0.3.6)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.3.0)
      loofah (~> 2.3)
    rails-i18n (6.0.0)
      i18n (>= 0.7, < 2)
      railties (>= 6.0.0, < 7)
    rails_best_practices (1.20.0)
      activesupport
      code_analyzer (>= 0.5.1)
      erubis
      i18n
      json
      require_all (~> 3.0)
      ruby-progressbar
    railties (6.0.3.6)
      actionpack (= 6.0.3.6)
      activesupport (= 6.0.3.6)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.20.3, < 2.0)
    rainbow (3.0.0)
    rake (13.0.3)
    ransack (2.4.2)
      activerecord (>= 5.2.4)
      activesupport (>= 5.2.4)
      i18n
    rb-fsevent (0.10.4)
    rb-inotify (0.10.1)
      ffi (~> 1.0)
    regexp_parser (2.1.1)
    require_all (3.0.0)
    responders (3.0.1)
      actionpack (>= 5.0)
      railties (>= 5.0)
    rexml (3.2.4)
    rotp (6.2.0)
    rspec (3.10.0)
      rspec-core (~> 3.10.0)
      rspec-expectations (~> 3.10.0)
      rspec-mocks (~> 3.10.0)
    rspec-core (3.10.1)
      rspec-support (~> 3.10.0)
    rspec-expectations (3.10.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.10.0)
    rspec-mocks (3.10.2)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.10.0)
    rspec-rails (4.1.2)
      actionpack (>= 4.2)
      activesupport (>= 4.2)
      railties (>= 4.2)
      rspec-core (~> 3.10)
      rspec-expectations (~> 3.10)
      rspec-mocks (~> 3.10)
      rspec-support (~> 3.10)
    rspec-support (3.10.2)
    rspec_api_documentation (6.1.0)
      activesupport (>= 3.0.0)
      mustache (~> 1.0, >= 0.99.4)
      rspec (~> 3.0)
    rubocop (0.85.1)
      parallel (~> 1.10)
      parser (>= 2.7.0.1)
      rainbow (>= 2.2.2, < 4.0)
      regexp_parser (>= 1.7)
      rexml
      rubocop-ast (>= 0.0.3)
      ruby-progressbar (~> 1.7)
      unicode-display_width (>= 1.4.0, < 2.0)
    rubocop-ast (1.4.1)
      parser (>= 2.7.1.5)
    rubocop-performance (1.6.1)
      rubocop (>= 0.71.0)
    ruby-progressbar (1.11.0)
    ruby-vips (2.1.0)
      ffi (~> 1.12)
    ruby2_keywords (0.0.4)
    sass-rails (6.0.0)
      sassc-rails (~> 2.1, >= 2.1.1)
    sassc (2.4.0)
      ffi (~> 1.9)
    sassc-rails (2.1.2)
      railties (>= 4.0.0)
      sassc (>= 2.0)
      sprockets (> 3.0)
      sprockets-rails
      tilt
    selectize-rails (0.12.6)
    sentry-rails (4.3.3)
      railties (>= 5.0)
      sentry-ruby-core (~> 4.3.0)
    sentry-ruby (4.3.1)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      faraday (>= 1.0)
      sentry-ruby-core (= 4.3.1)
    sentry-ruby-core (4.3.1)
      concurrent-ruby
      faraday
    sexp_processor (4.15.2)
    shoulda-matchers (4.5.1)
      activesupport (>= 4.2.0)
    shrine (3.3.0)
      content_disposition (~> 1.0)
      down (~> 5.1)
    sixarm_ruby_unaccent (1.2.0)
    sorbet-runtime (0.5.6357)
    spring (2.1.1)
    spring-watcher-listen (2.0.1)
      listen (>= 2.7, < 4.0)
      spring (>= 1.2, < 3.0)
    sprockets (4.0.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.2)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    standard (0.4.7)
      rubocop (~> 0.85.0)
      rubocop-performance (~> 1.6.0)
    tailwindcss (1.0.3)
      railties (>= 4.1.0, <= 6.1)
    thor (1.1.0)
    thread_safe (0.3.6)
    tilt (2.0.10)
    timecop (0.9.4)
    timeliness (0.4.4)
    tinymce-rails (5.7.1)
      railties (>= 3.1.1)
    to_bool (2.0.0)
    turbolinks (5.2.1)
      turbolinks-source (~> 5.2)
    turbolinks-source (5.2.0)
    tzinfo (1.2.9)
      thread_safe (~> 0.1)
    unicode-display_width (1.7.0)
    unicode_utils (1.4.0)
    uniform_notifier (1.14.2)
    validates_timeliness (4.1.1)
      timeliness (>= 0.3.10, < 1)
    warden (1.2.9)
      rack (>= 2.0.9)
    warden-jwt_auth (0.5.0)
      dry-auto_inject (~> 0.6)
      dry-configurable (~> 0.9)
      jwt (~> 2.1)
      warden (~> 1.2)
    web-console (4.1.0)
      actionview (>= 6.0.0)
      activemodel (>= 6.0.0)
      bindex (>= 0.4.0)
      railties (>= 6.0.0)
    webpacker (4.3.0)
      activesupport (>= 4.2)
      rack-proxy (>= 0.6.1)
      railties (>= 4.2)
    websocket-driver (0.7.3)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.5)
    zeitwerk (2.4.2)

PLATFORMS
  x86_64-linux

DEPENDENCIES
  action_policy (~> 0.4.4)
  activerecord-nulldb-adapter (~> 0.4.0)
  administrate (~> 0.14.0)
  aliyunsdkcore (~> 0.0.16)
  apitome!
  aws-sdk-s3 (~> 1.75)
  bootsnap (>= 1.4.2)
  bullet (~> 6.1)
  byebug
  countries (~> 3.0)
  database_cleaner-active_record (~> 1.8)
  devise (~> 4.7)
  devise-i18n (~> 1.9)
  devise-jwt (~> 0.8.0)
  dotenv-rails (~> 2.7)
  factory_bot_rails (~> 6.1)
  faker (~> 2.13)
  faraday (~> 1.3)
  image_processing (~> 1.8)
  json_translate (~> 4.0)
  jsonapi.rb!
  language_filter (~> 0.3.1)
  letter_opener (~> 1.7)
  letter_opener_web (~> 1.4)
  listen (~> 3.2)
  nexmo (~> 7.2)
  pg (>= 0.18, < 2.0)
  pg_search (~> 2.3)
  phonelib (~> 0.6.44)
  puma (~> 4.1)
  rack-cors (~> 1.1)
  rack-throttle (~> 0.7.0)
  rails (~> 6.0.3, >= 6.0.3.2)
  rails-i18n (~> 6.0)
  rails_best_practices (~> 1.20)
  rotp (~> 6.0)
  rspec-rails (~> 4.0)
  rspec_api_documentation (~> 6.1)
  ruby-vips (~> 2.0)
  sass-rails (>= 6)
  sentry-rails (~> 4.2)
  sentry-ruby (~> 4.2)
  shoulda-matchers (~> 4.3)
  shrine (~> 3.3.0)
  spring
  spring-watcher-listen (~> 2.0.0)
  standard (~> 0.4.7)
  tailwindcss (~> 1.0)
  timecop (~> 0.9.1)
  tinymce-rails (~> 5.5)
  to_bool (~> 2.0)
  turbolinks (~> 5)
  tzinfo-data
  validates_timeliness (~> 4.1)
  web-console (>= 3.3.0)
  webpacker (~> 4.0)

RUBY VERSION
   ruby 2.6.6p146

BUNDLED WITH
   2.2.14

Guess I came at the right time!

I am also getting this error on the following versions:

Using sentry-ruby-core 4.3.1
Using sentry-rails 4.3.3
Using sentry-ruby 4.3.1

Downgrading to the following works fine:

Using sentry-ruby-core 4.3.1
Using sentry-rails 4.3.2
Using sentry-ruby 4.3.1

Stack trace up until my code:

     5: from /Users/chew/.rvm/gems/ruby-2.7.2/gems/sentry-ruby-core-4.3.1/lib/sentry-ruby.rb:68:in `init'
     4: from /Users/chew/.rvm/gems/ruby-2.7.2/gems/sentry-ruby-core-4.3.1/lib/sentry-ruby.rb:68:in `new'
     3: from /Users/chew/.rvm/gems/ruby-2.7.2/gems/sentry-ruby-core-4.3.1/lib/sentry/client.rb:17:in `initialize'
     2: from /Users/chew/.rvm/gems/ruby-2.7.2/gems/sentry-ruby-core-4.3.1/lib/sentry/client.rb:17:in `new'
     1: from /Users/chew/.rvm/gems/ruby-2.7.2/gems/sentry-ruby-core-4.3.1/lib/sentry/transport/http_transport.rb:15:in `initialize'
/Users/chew/.rvm/gems/ruby-2.7.2/gems/sentry-ruby-core-4.3.1/lib/sentry/transport/http_transport.rb:53:in `set_conn': undefined method `debug' for nil:NilClass (NoMethodError)
Did you mean?  debugger

@st0012

I think running bundle update it's enough to make everything update including sentry-ruby 4.3 if I define sentry-ruby "~> 4.2"

this looks identical to https://github.com/getsentry/sentry-ruby/issues/1365

can you move your Sentry configuration into its own initializer file? config/initializers/sentry.rb

solved

Sentry.init do |config| config.dsn = ENV['DSN_SENTRY'] config.logger = Sentry::Logger.new(STDOUT) config.traces_sample_rate = 0.5 end

@st0012 thanks a lot you save my day!

Moving it fixed it for me too. Thank you!

no problem, happy to help 馃檪

Was this page helpful?
0 / 5 - 0 ratings