aserafin / grape_logging

Request logging for Grape!
MIT License
147 stars 76 forks source link

uninitialized constant ActiveSupport::ParameterFilter in version 1.8.3 with rails 6 #66

Closed SimonVillage closed 4 years ago

SimonVillage commented 4 years ago

I am on Rails 6. Version 1.8.2 and 1.8.3 and throwing following error:

`block in load_missing_constant': uninitialized constant ActiveSupport::ParameterFilter (NameError)

however 1.8.1 is working. Disabling the gem makes the app work again:

Loading development environment (Rails 6.0.0)
irb(main):001:0> ActiveSupport::ParameterFilter
=> ActiveSupport::ParameterFilter
exosty commented 4 years ago

adding explicit require 'active_support/parameter_filter' in application.rb solved my problem. It seems like gem was loading earlier than active_support/parameter_filter during initialization process somehow

SimonVillage commented 4 years ago

can confirm that this solved my issue. I will keep it anyway open.

flanger001 commented 4 years ago

I am also getting this on a brand new Ruby 2.7.0 & Rails 6.0.3.2 application. Here is my Gemfile:

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

ruby `cat .ruby-version`.chomp # 2.7.0

gem "bcrypt"
gem "bootsnap", require: false
gem "pg"
gem "puma"
gem "rack-cors"
gem "rails"
gem "rubocop"

# Grape
gem "grape"
gem "grape-entity"
gem "grape_logging"
gem "grape-swagger"
gem "grape-swagger-entity"

group :development, :test do
  gem "rspec-rails"
  gem "pry-rails"
end

group :test do
  gem "webmock"
end

group :development do
  gem "listen"
end

Here is the full stack trace:

18: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.3.2/lib/rails/commands.rb:18:in `<top (required)>'
17: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.3.2/lib/rails/command.rb:46:in `invoke'
16: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.3.2/lib/rails/command/base.rb:69:in `perform'
15: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
14: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
13: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
12: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.3.2/lib/rails/commands/server/server_command.rb:138:in `perform'
11: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.3.2/lib/rails/commands/server/server_command.rb:138:in `tap'
10: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.3.2/lib/rails/commands/server/server_command.rb:141:in `block in perform'
9: from /Users/davidshaffer/Dropbox/Coding/Personal/Apps/cover_band/cover_band_api/config/application.rb:20:in `<top (required)>'
8: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler.rb:174:in `require'
7: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
6: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
5: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require'
4: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each'
3: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require'
2: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/runtime.rb:74:in `require'
1: from /Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/grape_logging-1.8.3/lib/grape_logging.rb:17:in `<top (required)>'
/Users/davidshaffer/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/grape_logging-1.8.3/lib/grape_logging/util/parameter_filter.rb:9:in `<top (required)>': uninitialized constant ActiveSupport::ParameterFilter (NameError)

Adding require "active_support/parameter_filter" to the top of application.rb does fix this, however this seems subpar. This is weird because I have some applications that have this same setup and work without the ParameterFilter requirement, though I would be willing to bet the reason those apps work and this one doesn't is because they load all of ActiveSupport by the time this gem is loaded.

aserafin commented 4 years ago

fixed with https://github.com/aserafin/grape_logging/pull/72 thanks again @flanger001 💪