4

I have a node app that I am deploying through Gitlab. I am using docker image node:12.8.0.

Recently it has been failing deployment with the following error

 $ dpl --provider=heroku --app=$HEROKU_DEVELOPMENT_APP --api-key=$HEROKU_API_KEY --skip-cleanup
 Installing deploy dependencies
 ERROR:  Error installing dpl-heroku:
     faraday requires Ruby version >= 2.4.
 Successfully installed multipart-post-2.1.1
 Successfully installed ruby2_keywords-0.0.2
 /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- dpl/provider/heroku (LoadError)
     from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
     from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/provider.rb:93:in `rescue in block in new'
     from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/provider.rb:68:in `block in new'
     from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/cli.rb:41:in `fold'
     from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/provider.rb:67:in `new'
     from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/cli.rb:31:in `run'
     from /var/lib/gems/2.3.0/gems/dpl-1.10.15/lib/dpl/cli.rb:7:in `run'
     from /var/lib/gems/2.3.0/gems/dpl-1.10.15/bin/dpl:5:in `'
     from /usr/local/bin/dpl:22:in `load'
     from /usr/local/bin/dpl:22:in `'
 Running after_script
 00:01
 Running after script...
 $ echo "Job - $CI_JOB_NAME ended."
 Job - deploy_development ended.
 Cleaning up file based variables
 00:01
 ERROR: Job failed: exit code 1

I am unable to install Ruby2.4 through apt-get install ruby2.4.

Any advice would be appreciated. Thanks

Devatanu
  • 507
  • 5
  • 13

2 Answers2

6

I had the same problem today in Gitlab CI.

The problem is that Node uses debian stretch (version 9) by default as the base for docker images, at least in the 12.x LTS versions. This version of debian has Ruby 2.3.3 by default in the repositories, which is not supported by Faraday, which requires a version equal to or greater than 2.4.

What I did was use the 12.x-buster tag (notice the -buster at the end of the version tag) and in these images of docker Node uses debian buster (version 10) as a base. This version of debian has Ruby 2.5.5 repositories by default, which allows Faraday to be installed and therefore dpl for heroku works normally.

Cristiam Mercado
  • 573
  • 12
  • 34
  • 1
    Thanks A lot Sr, I got stuck on this one the entire morning. This always worked, It just stated failing for me like 3 days ago. I guess some update on dpl... – Giovanii Mirko Terrazas Oct 19 '20 at 21:20
  • 1
    Struggled with this all night. Thanks a lot – Joshua Oluikpe Apr 07 '21 at 10:29
  • Are you referring to the node:version? I tried using node:12.13.0-buster but still fails with "/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)". Any ideas? – Jarek Ostrowski Jan 04 '22 at 18:10
  • @JarekOstrowski You may preinstall faraday 1.8.0 before running dpl. This solves same issue for me. – sunki Jan 04 '22 at 19:38
0

Those running into this issue on travis-ci, I was able to do it by adding a before_deploy command to specify the version of faraday to use.

...
before_deploy:
  - rvm $(travis_internal_ruby) --fuzzy do ruby -S gem install faraday -v 1.8.0
deploy:
  provider: heroku
  api_key: $HEROKU_API_KEY
...

More details: https://travis-ci.community/t/heroku-deploy-fails-installing-dpl-heroku-encounters-faraday-error/12563/6?u=hallmanitor

hallmanitor
  • 318
  • 1
  • 4
  • 9