Closed jrmhaig closed 1 month ago
However, I think that the two versions are so different that they cannot both be supported at the same time.
Have you run into specific issues? Faraday extracted pieces of the core middleware from faraday 1 into a separate gem so that one could upgrade cleanly, thus allowing gems to depend safely across versions 1 and 2.
From https://github.com/lostisland/faraday/blob/main/UPGRADING.md#so-what-will-this-mean-for-me
All adapters, except for the net_http one, have already been moved out and released as separate gems. They've then been re-added into Faraday's v1 dependencies so that you wouldn't notice. This means that immediately after v2.0 will be released, all the adapters that were previously available will be already compatible with Faraday 2.0!
However, I think that the two versions are so different that they cannot both be supported at the same time.
Have you run into specific issues? Faraday extracted pieces of the core middleware from faraday 1 into a separate gem so that one could upgrade cleanly, thus allowing gems to depend safely across versions 1 and 2.
The specific issue I have found is:
/home/circleci/vendor/bundle/ruby/3.1.0/gems/json_api_client-1.23.0/lib/json_api_client/connection.rb:27:in `use': uninitialized constant Faraday::Response::Json
faraday.builder.insert_before(::Faraday::Response::Json, middleware, *args, &block)
^^^^^^
Did you mean? JSON (NameError)
I briefly looked at this and saw that this had been changed to use ::Faraday::Response::Json
as part of the PR to support Faraday 2 so I presumed that this had made it incompatible with version 1. I see now that Faraday::Response::Json
does indeed exist in version one and has been created specifically to permit support for both versions at the same time. However, I see that this class is not loaded automatically in version 1 as it is with version 2 so;
# With Faraday 1
irb(main):001> require 'faraday'
=> true
irb(main):002> Faraday::Response::Json
(irb):2:in `<main>': uninitialized constant Faraday::Response::Json (NameError)
# With Faraday 2
irb(main):001> require 'faraday'
=> true
irb(main):002> Faraday::Response::Json
=> Faraday::Response::Json
This appears to be a problem with the Faraday gem so I'll raise an issue there instead.
Thank you for your time.
It turns out that the problem was due to a conflict with faraday_middleware
, which you have removed and we needed to add back in for another middleware. There is now an update to that gem that fixes that conflict so we are able to have it until we have removed that requirement. I'll close this ticket now. Thanks.
The dependencies for version 1.23 allow for either version 1 or 2 of Faraday. However, I think that the two versions are so different that they cannot both be supported at the same time. I have found this whilst trying to update a project that has been neglected for a while with the minimum changes.
Would it make sense to update the gemspec file to only allow version 2?