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

Faraday 1.9.0 should depend on faraday-httpclient 1.0 #1368

Closed
jcoyne opened this issue Jan 6, 2022 · 10 comments
Closed

Faraday 1.9.0 should depend on faraday-httpclient 1.0 #1368

jcoyne opened this issue Jan 6, 2022 · 10 comments

Comments

@jcoyne
Copy link

jcoyne commented Jan 6, 2022

Currently it will install faraday-httpclient 2.0 resulting in an error like:

Failure/Error: require 'faraday'

LoadError:
  cannot load such file -- httpclient
# /home/circleci/.rubygems/gems/faraday-httpclient-2.0.0/lib/faraday/httpclient.rb:3:in `require'
# /home/circleci/.rubygems/gems/faraday-httpclient-2.0.0/lib/faraday/httpclient.rb:3:in `<top (required)>'
# /home/circleci/.rubygems/gems/faraday-1.9.0/lib/faraday.rb:39:in `require'
# /home/circleci/.rubygems/gems/faraday-1.9.0/lib/faraday.rb:39:in `<top (required)>

https://github.com/lostisland/faraday/blob/1.x/faraday.gemspec#L21

@iMacTia
Copy link
Member

iMacTia commented Jan 6, 2022

Sorry @jcoyne, hotfixes for all the 2.0 adapters are on their way, I only did net_http this morning (being the most popular one) but I'd expect the others to be fixed very soon as well

@jcoyne
Copy link
Author

jcoyne commented Jan 6, 2022

Ah, so since Faraday 1.9 requires all the adapters, it's a problem if even one of them has this problem: https://github.com/lostisland/faraday/blob/1.x/lib/faraday.rb#L38-L43

@danielsaraivatt
Copy link

Possibly related to this, but a github action unsplash/comment-on-pr started failing recently with the following message:

  Step 8/10 : RUN gem install octokit
   ---> Running in 5b5aad3fc1df
  ERROR:  While executing gem ... (Gem::Resolver::Molinillo::CircularDependencyError)
      There is a circular dependency between faraday-patron and faraday

@iMacTia
Copy link
Member

iMacTia commented Jan 6, 2022

All v2 adapters have been fixed (re-released as 2.0.1) and Faraday 1.9.1 has been release which lowers the preferred version for all adapters to stay below 2.0 (as the title of this issue correctly suggested).
The problem I missed initially was that v2.0 of the different adapters have a hard dependency on the underlying client library they wrap, and that conflicted with the dynamic dependency loading of Faraday v1.

@hankcs
Copy link

hankcs commented Apr 25, 2022

With faraday-1.9.3, I still constantly get this:

missing dependency for Faraday::Adapter::HTTPClient: cannot load such file -- httpclient

I tried to require it and everyting works file, httpclient is right here but faraday just cannot import it.

require 'httpclient'
clnt = HTTPClient.new

@hankcs
Copy link

hankcs commented Apr 25, 2022

ls vendor/bundle/ruby/2.7.0/gems/ | grep http
faraday-em_http-1.0.0
faraday-httpclient-1.0.1
faraday-net_http-1.0.1
faraday-net_http_persistent-1.2.0
http_accept_language-2.1.1
httpclient-2.8.3

ls vendor/bundle/ruby/2.7.0/gems/ | grep fara
faraday-1.0.1
faraday-1.1.0
faraday-1.10.0
faraday-1.2.0
faraday-1.8.0
faraday-1.9.3
faraday-em_http-1.0.0
faraday-em_synchrony-1.0.0
faraday-excon-1.1.0
faraday-httpclient-1.0.1
faraday-multipart-1.0.3
faraday-net_http-1.0.1
faraday-net_http_persistent-1.2.0
faraday-patron-1.0.0
faraday-rack-1.0.0
faraday-retry-1.0.3

@iMacTia
Copy link
Member

iMacTia commented Apr 26, 2022

@hankcs your issue looks slightly different from the one in the issue.
I'm not too familiar with the missing dependency for ... error, but it might be due to the way bundler is managing your dependencies.
ls vendor/bundle/ruby/2.7.0/gems/ will show you a list of installed gems in your system, but if you run a project using Bundler (i.e. with a Gemfile) then only the gems listed in the Gemfile will be considered, especially if you run something with bundle exec ....

I'd be happy to help but I'd need additional information to understand what's wrong.

  1. Is there additional information available (e.g. a stacktrace) when you see that error?
  2. What type of code are you running? Is it a plain Ruby script, a Rails project or something else?
  3. Do you have a Gemfile? Is httpclient in it?
  4. How do you get the error you're seeing? What are you running when that appears?

@hankcs
Copy link

hankcs commented Apr 26, 2022

Hi @iMacTia , thanks for your prompt response.

  1. Sorry I don't have the full stacktrace but I remember it's thrown from vendor/bundle/ruby/2.7.0/gems/faraday-1.9.3/lib/faraday/dependency_loader.rb 37L
  2. I'm running with a discourse project which utilizes discourse-elasticsearch, and discourse-elasticsearch calls faraday. I tested with rake elasticsearch:reindex_posts so it's quite complicated to locate the cause.
  3. discourse-elasticsearch has listed httpclient in its plugin.rb and I can confirm it's installed to the plugin's gem folder.
  4. The rake and discourse mechanism of loading gems could be the fault. After specify a different adapter instead of httpclient, this error is gone. So it's not really the bug in faraday.

@iMacTia
Copy link
Member

iMacTia commented Apr 27, 2022

@hankcs that was my guess as well, there seems to be an issue with how dependencies are managed in the project.
I had a quick look because I really wanted to help out, but I'm honestly unfamiliar with this plugin.rb files system 🤔.
I found this thread that explain a few things but I couldn't find any specific documentation that would explain why the require 'httpclient' would fail.
This may be due to the load_path not being set correctly.

If your project does have a Gemfile, my suggestion would be to put httpclient in there, but it would be great to understand how to make it work without that as well

@hankcs
Copy link

hankcs commented May 3, 2022

@hankcs that was my guess as well, there seems to be an issue with how dependencies are managed in the project. I had a quick look because I really wanted to help out, but I'm honestly unfamiliar with this plugin.rb files system 🤔. I found this thread that explain a few things but I couldn't find any specific documentation that would explain why the require 'httpclient' would fail. This may be due to the load_path not being set correctly.

If your project does have a Gemfile, my suggestion would be to put httpclient in there, but it would be great to understand how to make it work without that as well

Yes, I ended up with using the nethttp that is included in the Gemfile by the discourse core.

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

4 participants