lostisland/faraday

An attempt to run a request with a Faraday::Connection without adapter has been made. (RuntimeError)

jareko999 opened this issue ยท 6 comments

Basic Info

  • Faraday Version: 2.0.0, from the job log
  • Ruby Version: latest
  • Node Version: latest

Issue description

GitLab CI failing due to:

/usr/local/bundle/gems/faraday-2.0.0/lib/faraday/rack_builder.rb:230:in ensure_adapter!': An attempt to run a request with a Faraday::Connection without adapter has been made. (RuntimeError) Please set Faraday.default_adapter or provide one when initializing the connection.

My CI file deployed just fine yesterday. See my versions above.

CI File

image: node:latest
stages:
  - production

production:
  type: deploy
  stage: production
  image: ruby:latest
  script:
    - apt-get update -qy
    - apt-get install -y ruby-dev
    - gem install dpl
    - dpl --provider=heroku --app=blueprint-careers --api-key=$HEROKU_API_KEY
  only:
    - master

Job output

$ gem install dpl
Successfully installed dpl-1.10.16
1 gem installed
$ dpl --provider=heroku --app=blueprint-careers --api-key=$HEROKU_API_KEY
Installing deploy dependencies
Successfully installed rendezvous-0.1.3
Successfully installed netrc-0.11.0
Successfully installed faraday-2.0.0
Successfully installed dpl-heroku-1.10.16
4 gems installed
Preparing deploy
No stash entries found.
/usr/local/bundle/gems/faraday-2.0.0/lib/faraday/rack_builder.rb:230:in `ensure_adapter!': An attempt to run a request with a Faraday::Connection without adapter has been made. (RuntimeError)
Please set Faraday.default_adapter or provide one when initializing the connection.
For more info, check https://lostisland.github.io/faraday/usage/.
	from /usr/local/bundle/gems/faraday-2.0.0/lib/faraday/rack_builder.rb:166:in `app'
	from /usr/local/bundle/gems/faraday-2.0.0/lib/faraday/rack_builder.rb:153:in `build_response'
	from /usr/local/bundle/gems/faraday-2.0.0/lib/faraday/connection.rb:445:in `run_request'
	from /usr/local/bundle/gems/faraday-2.0.0/lib/faraday/connection.rb:200:in `get'
	from /usr/local/bundle/gems/dpl-heroku-1.10.16/lib/dpl/provider/heroku/generic.rb:43:in `check_auth'
	from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/provider.rb:187:in `block in deploy'
	from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/cli.rb:41:in `fold'
	from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/provider.rb:186:in `deploy'
	from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/cli.rb:32:in `run'
	from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/cli.rb:7:in `run'
	from /usr/local/bundle/gems/dpl-1.10.16/bin/dpl:5:in `<top (required)>'
	from /usr/local/bundle/bin/dpl:25:in `load'
	from /usr/local/bundle/bin/dpl:25:in `<main>'

Hi @jareko999, you (or a gem you depend on) have just updated Faraday to v2.0.
This being a major version, it comes with some backwards incompatible changes, including the one causing the error you see.
Please refer to the UPGRADING.md file for instructions on how to upgrade, or simply fix the Faraday version to < 2.0 in your Gemfile.

#1360 see here for a workaround for that specific gem.

I'm leaving this open for the time being as I'd expect more people falling into this. Marked it with info label

Thanks. Looks like dpl was the culprit.

This workaround worked for me: travis-ci/dpl#1247 (comment).

This is my update for Gitlab CI, works perfectly with Faraday 1.8.0

deploy:
  stage: deploy
  only:
    - master
  image: ruby:latest
  script:
    - gem install dpl && gem install faraday -v 1.8.0
    - dpl --provider=heroku --app=xxx --api-key=$HEROKU_API_KEY

I'm closing this because Faraday 2.0.1 has now re-introduced net_http as both a dependency and the default adapter, so there's no need for workarounds anymore ๐ŸŽ‰