GithubHelp home page GithubHelp logo

Comments (10)

e-e avatar e-e commented on June 20, 2024 1

@EmilioCristalli I don't know what is different, but I created a new test server instance, and now it seems to be loading that gem properly. Thanks for the help

from exception_notification.

e-e avatar e-e commented on June 20, 2024

Some notes:

Using the require in the error.rb initializer
Results in

/usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require': cannot load such file -- exception_notification (LoadError)

(Same as posted above)

Not using bootsnap
Commenting out require 'bootsnap/setup' in the config/boot.rb file results in basically the same error, just with zeitwerk

/usr/local/bundle/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in require': cannot load such file -- exception_notification/rails`

Not using the require
Results in uninitialized constant ExceptionNotification (NameError)

I've tried deleting rm tmp/cache/bootsnap-load-path-cache and there was no change in behavior.

Changing RAILS_ENV, RACK_ENV, AND NODE_ENV from production to development in my .env file (on the same production server) results in the server actually starting up and running, but the notification is not sent to slack as it is in my local development environment.

from exception_notification.

EmilioCristalli avatar EmilioCristalli commented on June 20, 2024

hi @e-e!

Not sure if i understand your problem. Is it working in any environment at all?
Did you add the gems to any specific group in the Gemfile?

I think the require 'exception_notification' shouldn't be necessary because Rails loads all gems by default.
But the require might not work in certain environments, though, if you are only installing the gem in specific groups, ie:

group :development, :test do
  gem 'exception_notification'
  gem 'slack-notifier'
end

You can also try to configure your notifications like the Readme suggest, either by using an initializer like this (or running rails g exception_notification:install ):

require 'exception_notification/rails'

ExceptionNotification.configure do |config|
  config.add_notifier slack: {
        :webhook_url => ENV["SLACK_ERROR_WEBHOOOK_URL"]
    }
end

or adding the middleware in your application or an environment config file (like config/production.rb):

Rails.application.configure do
  config.middleware.use ExceptionNotification::Rack, slack: {
        :webhook_url => ENV["SLACK_ERROR_WEBHOOOK_URL"]
    }
end

from exception_notification.

e-e avatar e-e commented on June 20, 2024

Hi @EmilioCristalli

It does work if i'm not running the app in production mode (i.e., development mode). I tried adding

config.middleware.use ExceptionNotification::Rack, slack: {
        :webhook_url => ENV["SLACK_ERROR_WEBHOOOK_URL"]
}

to my config/production.rb file, but I am still getting the same error (unitialized contant ExceptionNotification when trying it in the config/production.rb file, and the bootsnap/zeitwerk autoload error when doing it in the initializer)

from exception_notification.

EmilioCristalli avatar EmilioCristalli commented on June 20, 2024

@e-e what about your gemfile? is gem 'exception_notification' inside of a group?
can you post here your Gemfiel, or at least the relevant parts to reproduce the error?

from exception_notification.

e-e avatar e-e commented on June 20, 2024

@EmilioCristalli No it's not in a group:

Gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2', '>= 6.0.2.1'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3', '~> 1.4'
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
gem 'bcrypt', '~> 3.1.7'

gem 'faraday'

# natural language processing
# - note: can't install this right now because it requires
#   FreeLing and a mecab library, and I don't think FreeLing
#   can be installed on alpine linux?
# gem 've', '~> 0.0.3'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails', '~> 4.0.1'
  gem 'pry', '~> 0.12.2'
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  # gem 'spring'
  # gem 'spring-watcher-listen', '~> 2.0.0'
  gem "better_errors"
  gem "binding_of_caller"
  gem "seed_dump", "~> 3.3"
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

gem 'bootstrap', '~> 4.0.0'
gem 'jquery-rails', '~> 4.3.5'
gem 'draper', '~> 4.0.0'
gem 'i18n-tasks', '~> 0.9.31'
gem 'aws-sdk-s3', '~> 1'
gem "react-rails"

gem 'exception_notification'
gem 'slack-notifier'

from exception_notification.

e-e avatar e-e commented on June 20, 2024

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (6.0.2.1)
      actionpack (= 6.0.2.1)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailbox (6.0.2.1)
      actionpack (= 6.0.2.1)
      activejob (= 6.0.2.1)
      activerecord (= 6.0.2.1)
      activestorage (= 6.0.2.1)
      activesupport (= 6.0.2.1)
      mail (>= 2.7.1)
    actionmailer (6.0.2.1)
      actionpack (= 6.0.2.1)
      actionview (= 6.0.2.1)
      activejob (= 6.0.2.1)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (6.0.2.1)
      actionview (= 6.0.2.1)
      activesupport (= 6.0.2.1)
      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.2.1)
      actionpack (= 6.0.2.1)
      activerecord (= 6.0.2.1)
      activestorage (= 6.0.2.1)
      activesupport (= 6.0.2.1)
      nokogiri (>= 1.8.5)
    actionview (6.0.2.1)
      activesupport (= 6.0.2.1)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.1, >= 1.2.0)
    activejob (6.0.2.1)
      activesupport (= 6.0.2.1)
      globalid (>= 0.3.6)
    activemodel (6.0.2.1)
      activesupport (= 6.0.2.1)
    activemodel-serializers-xml (1.0.2)
      activemodel (> 5.x)
      activesupport (> 5.x)
      builder (~> 3.1)
    activerecord (6.0.2.1)
      activemodel (= 6.0.2.1)
      activesupport (= 6.0.2.1)
    activestorage (6.0.2.1)
      actionpack (= 6.0.2.1)
      activejob (= 6.0.2.1)
      activerecord (= 6.0.2.1)
      marcel (~> 0.3.1)
    activesupport (6.0.2.1)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
      zeitwerk (~> 2.2)
    addressable (2.7.0)
      public_suffix (>= 2.0.2, < 5.0)
    ast (2.4.0)
    autoprefixer-rails (9.7.4)
      execjs
    aws-eventstream (1.0.3)
    aws-partitions (1.287.0)
    aws-sdk-core (3.92.0)
      aws-eventstream (~> 1.0, >= 1.0.2)
      aws-partitions (~> 1, >= 1.239.0)
      aws-sigv4 (~> 1.1)
      jmespath (~> 1.0)
    aws-sdk-kms (1.30.0)
      aws-sdk-core (~> 3, >= 3.71.0)
      aws-sigv4 (~> 1.1)
    aws-sdk-s3 (1.61.1)
      aws-sdk-core (~> 3, >= 3.83.0)
      aws-sdk-kms (~> 1)
      aws-sigv4 (~> 1.1)
    aws-sigv4 (1.1.1)
      aws-eventstream (~> 1.0, >= 1.0.2)
    babel-source (5.8.35)
    babel-transpiler (0.7.0)
      babel-source (>= 4.0, < 6)
      execjs (~> 2.0)
    bcrypt (3.1.13)
    better_errors (2.6.0)
      coderay (>= 1.0.0)
      erubi (>= 1.0.0)
      rack (>= 0.9.0)
    bindex (0.8.1)
    binding_of_caller (0.8.0)
      debug_inspector (>= 0.0.1)
    bootsnap (1.4.6)
      msgpack (~> 1.0)
    bootstrap (4.0.0)
      autoprefixer-rails (>= 6.0.3)
      popper_js (>= 1.12.9, < 2)
      sass (>= 3.5.2)
    builder (3.2.4)
    byebug (11.1.1)
    capybara (3.31.0)
      addressable
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.8)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      regexp_parser (~> 1.5)
      xpath (~> 3.2)
    childprocess (3.0.0)
    coderay (1.1.2)
    concurrent-ruby (1.1.6)
    connection_pool (2.2.2)
    crass (1.0.6)
    debug_inspector (0.0.3)
    diff-lcs (1.4.4)
    draper (4.0.0)
      actionpack (>= 5.0)
      activemodel (>= 5.0)
      activemodel-serializers-xml (>= 1.0)
      activesupport (>= 5.0)
      request_store (>= 1.0)
    erubi (1.9.0)
    exception_notification (4.4.3)
      actionmailer (>= 4.0, < 7)
      activesupport (>= 4.0, < 7)
    execjs (2.7.0)
    faraday (1.0.1)
      multipart-post (>= 1.2, < 3)
    ffi (1.12.2)
    globalid (0.4.2)
      activesupport (>= 4.2.0)
    highline (2.0.3)
    i18n (1.8.2)
      concurrent-ruby (~> 1.0)
    i18n-tasks (0.9.31)
      activesupport (>= 4.0.2)
      ast (>= 2.1.0)
      erubi
      highline (>= 2.0.0)
      i18n
      parser (>= 2.2.3.0)
      rails-i18n
      rainbow (>= 2.2.2, < 4.0)
      terminal-table (>= 1.5.1)
    jbuilder (2.10.0)
      activesupport (>= 5.0.0)
    jmespath (1.4.0)
    jquery-rails (4.3.5)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    loofah (2.4.0)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.1)
      mini_mime (>= 0.1.1)
    marcel (0.3.3)
      mimemagic (~> 0.3.2)
    method_source (0.9.2)
    mimemagic (0.3.4)
    mini_mime (1.0.2)
    mini_portile2 (2.4.0)
    minitest (5.14.0)
    msgpack (1.3.3)
    multipart-post (2.1.1)
    nio4r (2.5.2)
    nokogiri (1.10.9)
      mini_portile2 (~> 2.4.0)
    parser (2.7.0.5)
      ast (~> 2.4.0)
    pg (1.2.2)
    popper_js (1.16.0)
    pry (0.12.2)
      coderay (~> 1.1.0)
      method_source (~> 0.9.0)
    public_suffix (4.0.3)
    puma (4.3.3)
      nio4r (~> 2.0)
    rack (2.2.2)
    rack-proxy (0.6.5)
      rack
    rack-test (1.1.0)
      rack (>= 1.0, < 3)
    rails (6.0.2.1)
      actioncable (= 6.0.2.1)
      actionmailbox (= 6.0.2.1)
      actionmailer (= 6.0.2.1)
      actionpack (= 6.0.2.1)
      actiontext (= 6.0.2.1)
      actionview (= 6.0.2.1)
      activejob (= 6.0.2.1)
      activemodel (= 6.0.2.1)
      activerecord (= 6.0.2.1)
      activestorage (= 6.0.2.1)
      activesupport (= 6.0.2.1)
      bundler (>= 1.3.0)
      railties (= 6.0.2.1)
      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)
    railties (6.0.2.1)
      actionpack (= 6.0.2.1)
      activesupport (= 6.0.2.1)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.20.3, < 2.0)
    rainbow (3.0.0)
    rake (13.0.1)
    rb-fsevent (0.10.3)
    rb-inotify (0.10.1)
      ffi (~> 1.0)
    react-rails (2.6.1)
      babel-transpiler (>= 0.7.0)
      connection_pool
      execjs
      railties (>= 3.2)
      tilt
    regexp_parser (1.7.0)
    request_store (1.5.0)
      rack (>= 1.4)
    rspec-core (3.9.2)
      rspec-support (~> 3.9.3)
    rspec-expectations (3.9.2)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.9.0)
    rspec-mocks (3.9.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.9.0)
    rspec-rails (4.0.1)
      actionpack (>= 4.2)
      activesupport (>= 4.2)
      railties (>= 4.2)
      rspec-core (~> 3.9)
      rspec-expectations (~> 3.9)
      rspec-mocks (~> 3.9)
      rspec-support (~> 3.9)
    rspec-support (3.9.3)
    ruby_dep (1.5.0)
    rubyzip (2.3.0)
    sass (3.7.4)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    sass-rails (6.0.0)
      sassc-rails (~> 2.1, >= 2.1.1)
    sassc (2.2.1)
      ffi (~> 1.9)
    sassc-rails (2.1.2)
      railties (>= 4.0.0)
      sassc (>= 2.0)
      sprockets (> 3.0)
      sprockets-rails
      tilt
    seed_dump (3.3.1)
      activerecord (>= 4)
      activesupport (>= 4)
    selenium-webdriver (3.142.7)
      childprocess (>= 0.5, < 4.0)
      rubyzip (>= 1.2.2)
    slack-notifier (2.3.2)
    sprockets (4.0.0)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    terminal-table (1.8.0)
      unicode-display_width (~> 1.1, >= 1.1.1)
    thor (1.0.1)
    thread_safe (0.3.6)
    tilt (2.0.10)
    turbolinks (5.2.1)
      turbolinks-source (~> 5.2)
    turbolinks-source (5.2.0)
    tzinfo (1.2.6)
      thread_safe (~> 0.1)
    unicode-display_width (1.7.0)
    web-console (4.0.1)
      actionview (>= 6.0.0)
      activemodel (>= 6.0.0)
      bindex (>= 0.4.0)
      railties (>= 6.0.0)
    webdrivers (4.2.0)
      nokogiri (~> 1.6)
      rubyzip (>= 1.3.0)
      selenium-webdriver (>= 3.0, < 4.0)
    webpacker (4.2.2)
      activesupport (>= 4.2)
      rack-proxy (>= 0.6.1)
      railties (>= 4.2)
    websocket-driver (0.7.1)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.4)
    xpath (3.2.0)
      nokogiri (~> 1.8)
    zeitwerk (2.3.0)

PLATFORMS
  ruby

DEPENDENCIES
  aws-sdk-s3 (~> 1)
  bcrypt (~> 3.1.7)
  better_errors
  binding_of_caller
  bootsnap (>= 1.4.2)
  bootstrap (~> 4.0.0)
  byebug
  capybara (>= 2.15)
  draper (~> 4.0.0)
  exception_notification
  faraday
  i18n-tasks (~> 0.9.31)
  jbuilder (~> 2.7)
  jquery-rails (~> 4.3.5)
  listen (>= 3.0.5, < 3.2)
  pg
  pry (~> 0.12.2)
  puma (~> 4.1)
  rails (~> 6.0.2, >= 6.0.2.1)
  react-rails
  rspec-rails (~> 4.0.1)
  sass-rails (>= 6)
  seed_dump (~> 3.3)
  selenium-webdriver
  slack-notifier
  turbolinks (~> 5)
  web-console (>= 3.3.0)
  webdrivers
  webpacker (~> 4.0)

RUBY VERSION
   ruby 2.6.3p62

BUNDLED WITH
   2.0.2

from exception_notification.

EmilioCristalli avatar EmilioCristalli commented on June 20, 2024

@e-e the only cause that comes to mind is that for some reason the gem is not being installed in production.
How do you deploy to production? is bundle install run automatically? is it possible that for some reason it is not being run and therefore the gem is not installed?

from exception_notification.

e-e avatar e-e commented on June 20, 2024

@EmilioCristalli That's the way that it seems, although I don't really even know where to start to figure out why. I've only been using ruby / rails for a few months, so it's sort of slow figuring these issues out. Here is the Dockerfile referenced from my compose file for the rails app:

FROM ruby:2.6.3-alpine

ENV BUNDLER_VERSION=2.0.2

RUN apk add --update --no-cache \
  binutils-gold \
  build-base \
  curl \
  file \
  g++ \
  gcc \
  git \
  less \
  libstdc++ \
  libffi-dev \
  libc-dev \ 
  linux-headers \
  libxml2-dev \
  libxslt-dev \
  libgcrypt-dev \
  make \
  netcat-openbsd \
  nodejs \
  openssl \
  pkgconfig \
  postgresql-dev \
  python \
  tzdata \
  yarn

RUN gem install bundler -v 2.0.2

WORKDIR /app

COPY Gemfile Gemfile.lock ./

RUN bundle config build.nokogiri --use-system-libraries

RUN bundle check || bundle install --force
RUN bundler exec rails webpacker:install
RUN bundler exec rails webpacker:install:react
RUN bundler exec rails generate react:install

RUN yarn --update-checksums
RUN yarn install --check-files

COPY . ./

RUN touch "log/$RAILS_ENV.log" && chmod 775 "log/$RAILS_ENV.log" 
RUN if [ "$RAILS_ENV" = "development" ] ; then chmod 775 touch log/test.log && chmod 775 log/test.log ; fi

ENTRYPOINT ["./docker/entrypoints/app-entrypoint.sh"]

It also seems like if bundle install wasn't running there were be other issues before getting to the exception_notification gem

from exception_notification.

EmilioCristalli avatar EmilioCristalli commented on June 20, 2024

do you have access to the logs from Docker? can you take a look at the output of the bundle check || bundle install --force command to verify if the gem is being installed?

from exception_notification.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.