travis-ci / travis.rb

Travis CI Client (CLI and Ruby library)
MIT License
1.59k stars 409 forks source link

travis login fails with uninitialized constant Faraday::Error::ConnectionFailed when Typhoeous < 1.4 is present #768

Closed shamazmazum closed 4 years ago

shamazmazum commented 4 years ago

Hello. travis login and travis login --pro fail with uninitialized constant Faraday::Error::ConnectionFailed

This is the report

System
Ruby:                     Ruby 2.6.6-p146
Operating System:         FreeBSD
RubyGems:                 RubyGems 3.0.6

CLI
Version:                  1.10.0
Plugins:                  none
Auto-Completion:          yes
Last Version Check:       2020-09-26 10:58:01 +0300

Session
API Endpoint:             https://api.travis-ci.com/
Logged In:                no
Verify SSL:               yes
Enterprise:               no

Endpoints
com:                      https://api.travis-ci.com/ (current)

Last Exception
An error occurred running `travis login --pro`:
    NameError: uninitialized constant Faraday::Error::ConnectionFailed
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/adapters/faraday.rb:106:in `block in request'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/request/callbacks.rb:146:in `block in execute_callbacks'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/request/callbacks.rb:145:in `each'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/request/callbacks.rb:145:in `execute_callbacks'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/request/operations.rb:35:in `finish'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/easy_factory.rb:164:in `block in set_callback'
        from /usr/local/lib/ruby/gems/2.6/gems/ethon-0.11.0/lib/ethon/easy/response_callbacks.rb:68:in `block in complete'
        from /usr/local/lib/ruby/gems/2.6/gems/ethon-0.11.0/lib/ethon/easy/response_callbacks.rb:68:in `each'
        from /usr/local/lib/ruby/gems/2.6/gems/ethon-0.11.0/lib/ethon/easy/response_callbacks.rb:68:in `complete'
        from /usr/local/lib/ruby/gems/2.6/gems/ethon-0.11.0/lib/ethon/easy/operations.rb:33:in `perform'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/request/operations.rb:16:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb:18:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/request/block_connection.rb:31:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/request/stubbable.rb:25:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/request/before.rb:26:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/adapters/faraday.rb:82:in `perform_request'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.3.1/lib/typhoeus/adapters/faraday.rb:72:in `call'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/request/retry.rb:148:in `call'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/request/url_encoded.rb:25:in `call'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/rack_builder.rb:153:in `build_response'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/connection.rb:492:in `run_request'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/connection.rb:198:in `get'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/client/session.rb:210:in `public_send'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/client/session.rb:210:in `block in raw'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/client/session.rb:283:in `block in instrumented'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/client/session.rb:284:in `block in instrumented'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/client/session.rb:285:in `instrumented'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/client/session.rb:208:in `raw'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/client/session.rb:187:in `get_raw'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/client/session.rb:135:in `config'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/cli/api_command.rb:132:in `load_gh'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/cli/login.rb:55:in `github'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/cli/login.rb:31:in `login'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/cli/login.rb:50:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/cli/command.rb:200:in `execute'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/lib/travis/cli.rb:64:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.10.0/bin/travis:18:in `<top (required)>'
        from /usr/local/bin/travis:23:in `load'
        from /usr/local/bin/travis:23:in `<main>'

This is the list of gems installed

rubygem-activesupport52-5.2.4.4 Utility classes and extension that are required by Rails MVC Framework
rubygem-addressable-2.7.0      Replacement for the URI implementation
rubygem-concurrent-ruby-1.1.7  Modern concurrency tools for Ruby
rubygem-ethon-0.11.0           Very lightweight libcurl wrapper
rubygem-faraday-1.0.1          HTTP/REST API client library in Ruby
rubygem-faraday_middleware-1.0.0 Collection of Ruby Faraday middlewares
rubygem-ffi-1.13.1_1           Extension for dynamic libraries & binding functions
rubygem-gh-0.18.0              Multi-layer client for the GitHub API v3
rubygem-highline-2.0.3         High-level IO library for command-line interfaces
rubygem-i18n-1.8.5,2           New wave Internationalization support for Ruby
rubygem-json-2.3.1             Parse JSON texts and generate them from ruby data structures
rubygem-json_pure-2.3.1        Parse JSON texts and generate them from ruby data structures in Ruby
rubygem-launchy-2.5.0          Helper class for launching cross-platform applications
rubygem-minitest-5.14.1        Minitest provides a complete suite of testing facilities
rubygem-multi_json-1.15.0      Ruby library provide swappable JSON backends
rubygem-multipart-post-2.1.1   Ruby Library that Use with Net::HTTP to do multipart form posts
rubygem-net-http-persistent2-2.9.4 Manages persistent connections using Net::HTTP
rubygem-net-http-pipeline-1.0.1 HTTP/1.1 pipelining implementation atop Net::HTTP
rubygem-public_suffix-4.0.6    Ruby domain name parser based on the Public Suffix List
rubygem-pusher-client-0.6.2    Client for consuming WebSockets from http://pusher.com
rubygem-thread_safe-0.3.6      Thread-safe collections and utilities for Ruby
rubygem-travis-1.10.0          CLI and Ruby client library for Travis CI
rubygem-typhoeus-1.3.1         Parallel HTTP request library
rubygem-tzinfo1-1.2.7          Daylight-savings aware timezone support for Ruby
rubygem-websocket-1.2.8        Universal Ruby library to handle WebSocket protocol

Can this be fixed?

BanzaiMan commented 4 years ago

How are you managing your ruby gems? It appears that the residual Typhoeus 1.3.1 is problematic in your case. (See https://github.com/typhoeus/typhoeus/issues/654)

Unfortunately, I don't think there is a way to specify optional runtime dependency in Rubygems, so we have to work around this problem.

Possible solutions

  1. Update typhoeus to version 1.4.0, which uses the correct Faraday 1.0-compatible constant: https://github.com/typhoeus/typhoeus/blob/v1.4.0/lib/typhoeus/adapters/faraday.rb#L106
  2. Delete typhoeus entirely, if you don't need this gem otherwise. CLI should continue to work.

Explanations:

The error message comes from this line https://github.com/typhoeus/typhoeus/blob/v1.3.1/lib/typhoeus/adapters/faraday.rb#L106 which is not compatible with Faraday 1.0.x

You need to update Typhoeus to v1.4.0 (as explained above) or uninstall it entirely; travis should work without it now (version 1.10.0 onward).

shamazmazum commented 4 years ago

Thanks, removed typhoeus, because after updating there is another message:

SSL peer certificate or SSH remote key was not OK
for a full error report, run travis report --pro
An error occurred running `travis login --pro`:
    Faraday::ConnectionFailed: SSL peer certificate or SSH remote key was not OK
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/adapters/faraday.rb:106:in `block in request'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/request/callbacks.rb:146:in `block in execute_callbacks'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/request/callbacks.rb:145:in `each'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/request/callbacks.rb:145:in `execute_callbacks'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/request/operations.rb:35:in `finish'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/easy_factory.rb:164:in `block in set_callback'
        from /usr/local/lib/ruby/gems/2.6/gems/ethon-0.11.0/lib/ethon/easy/response_callbacks.rb:68:in `block in complete'
        from /usr/local/lib/ruby/gems/2.6/gems/ethon-0.11.0/lib/ethon/easy/response_callbacks.rb:68:in `each'
        from /usr/local/lib/ruby/gems/2.6/gems/ethon-0.11.0/lib/ethon/easy/response_callbacks.rb:68:in `complete'
        from /usr/local/lib/ruby/gems/2.6/gems/ethon-0.11.0/lib/ethon/easy/operations.rb:33:in `perform'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/request/operations.rb:16:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb:18:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/request/block_connection.rb:31:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/request/stubbable.rb:25:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/request/before.rb:26:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/adapters/faraday.rb:82:in `perform_request'
        from /usr/local/lib/ruby/gems/2.6/gems/typhoeus-1.4.0/lib/typhoeus/adapters/faraday.rb:72:in `call'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/request/retry.rb:148:in `call'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/request/url_encoded.rb:25:in `call'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/rack_builder.rb:153:in `build_response'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/connection.rb:492:in `run_request'
        from /usr/local/lib/ruby/gems/2.6/gems/faraday-1.0.1/lib/faraday/connection.rb:198:in `get'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/client/session.rb:210:in `public_send'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/client/session.rb:210:in `block in raw'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/client/session.rb:283:in `block in instrumented'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/client/session.rb:284:in `block in instrumented'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/client/session.rb:285:in `instrumented'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/client/session.rb:208:in `raw'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/client/session.rb:187:in `get_raw'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/client/session.rb:135:in `config'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/cli/api_command.rb:126:in `load_gh'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/cli/login.rb:49:in `github'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/cli/login.rb:31:in `login'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/cli/login.rb:44:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/cli/command.rb:200:in `execute'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/lib/travis/cli.rb:64:in `run'
        from /usr/local/lib/ruby/gems/2.6/gems/travis-1.9.1/bin/travis:18:in `<top (required)>'
        from /usr/local/bin/travis:23:in `load'
        from /usr/local/bin/travis:23:in `<main>'

Without typhoeus all works. Gems come from FreeBSD ports and may be not up to date.