Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is version 1.23 compatible with Faraday 1? #414

Closed
jrmhaig opened this issue Sep 2, 2024 · 3 comments
Closed

Is version 1.23 compatible with Faraday 1? #414

jrmhaig opened this issue Sep 2, 2024 · 3 comments

Comments

@jrmhaig
Copy link

jrmhaig commented Sep 2, 2024

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?

@jasonkarns
Copy link

jasonkarns commented Sep 18, 2024

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!

@jrmhaig
Copy link
Author

jrmhaig commented Sep 19, 2024

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.

@jrmhaig
Copy link
Author

jrmhaig commented Sep 24, 2024

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.

@jrmhaig jrmhaig closed this as completed Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants