Add explicit runtime dependency on faraday itself
olbrich opened this issue · 2 comments
faraday-net_http/faraday-net_http.gemspec
Line 27 in 1b926b2
The gemspec declares faraday as a development dependency, but not a runtime one. Effectively this will allow this gem to be installed with any version of Faraday, even pre-1.0 versions.
Normally this won't cause problems, but if this gem appears earlier in your Gemfile than Faraday itself or another dependency that relies on Faraday, then you can get errors because the call to register_middleware
in
NoMethodError:
undefined method `register_middleware' for Faraday::Adapter:Class
Faraday::Adapter.register_middleware(net_http: Faraday::Adapter::NetHttp)
Hi @olbrich, we do this because net_http
is the default adapter and is included in Faraday's gemspec.
If we were to make it a runtime dependency, it would cause a circular dependency and bundler
would raise an error.
You're not supposed to add this gem directly in your Gemfile or require it in your project.
Think of it as a "bundled gem" that comes with Faraday 😄
I hope this clarifies but please do let me know if you have any follow-up question
Ah, that makes sense. I ran into this because I included 'faraday-net_http_persistent' in my bundle. It depends on faraday-net_http
, but not faraday
itself.