ruby-grape / grape

An opinionated framework for creating REST-like APIs in Ruby.
http://www.ruby-grape.org
MIT License
9.89k stars 1.22k forks source link

uninitialized constant Grape::Middleware::Base::Helpers after update to 1.2.5 #1939

Open seb-sykio opened 4 years ago

seb-sykio commented 4 years ago
/.rvm/gems/ruby-2.6.5/gems/grape-1.2.5/lib/grape/middleware/base.rb:6:in `<class:Base>': uninitialized constant Grape::Middleware::Base::Helpers (NameError)
    from .rvm/gems/ruby-2.6.5/gems/grape-1.2.5/lib/grape/middleware/base.rb:5:in `<module:Middleware>'
    from .rvm/gems/ruby-2.6.5/gems/grape-1.2.5/lib/grape/middleware/base.rb:4:in `<module:Grape>'
    from .rvm/gems/ruby-2.6.5/gems/grape-1.2.5/lib/grape/middleware/base.rb:3:in `<top (required)>'
    from .rvm/gems/ruby-2.6.5/gems/grape_logging-1.8.3/lib/grape_logging/middleware/request_logger.rb:1:in `<top (required)>'
dblock commented 4 years ago

That's not good. You got a project up that reproduces this? Or bisect it to a change?

seb-sykio commented 4 years ago

sorry, nothing online. the only solution I found for now is to remove gem "grape-logging"

robert-hromej commented 4 years ago

@dblock @seb-sykio try require 'grape' before require 'grape_logging'

dblock commented 4 years ago

If this fixes that feels like grape_logging should be doing a require 'grape'. Open an issue in that repo.

myxoh commented 4 years ago

Any updates?

pboling commented 4 years ago

CC @myxoh

@robert-hromej had the right idea.

If I move require 'grape_logging' to spot in the load order after I am sure grape has been loaded, then this error goes away. This gem, as is, doesn't load grape properly on it's own, but allowing bundler to load grape works.

In other words, if I have a require 'grape_logging' early on, before bundler loads my environment, then I get this error with latest version of grape.