Skip to main content

Dropping Support for Ruby Version 2.5 in Ruby SDKs

· 2 min read

We are now dropping support for Ruby version 2.5 in Ruby SDKs. Ruby 2.5 hit EOL status on 2021-03-31 as per the official source. As a result of dropping Ruby 2.5, we are now able to relax version constraints on some of the Ruby SDKs dependencies.

What was Supported Before?

Previously, the Ruby SDKs were compatible with the Ruby version >= 2.5. Due to the supported Ruby versions, the SDKs gemspec file was adding a version constraint on the faraday gem to be ('~> 1.0', '>= 1.0.1') as shown below:

s.add_dependency('faraday', '~> 1.0', '>= 1.0.1')
s.add_dependency('faraday_middleware', '~> 1.0')
s.required_ruby_version = ['>= 2.5']

What has Changed?

After terminating the support for Ruby 2.5, we can support the Faraday version ('~> 2.0', '>= 2.0.1'). It is a major release and changes the way to use Faraday as an ecosystem, rather than a library. You can read more about Faraday’s library in their changelog. One essential thing to notice is that from now onwards, all adapters and some middleware in Faraday have moved out and are being shipped as standalone gems. Therefore, we have to incorporate those dependencies in the gemspec file shown below.

  s.add_dependency('faraday', '~> 2.0', '>= 2.0.1')
s.add_dependency('faraday-follow_redirects', '~> 0.2')
s.add_dependency('faraday-multipart', '~> 1.0')
s.add_dependency('faraday-gzip', '~> 0.1')
s.add_dependency('faraday-retry', '~> 1.0')
s.required_ruby_version = ['>= 2.6']

Faraday Client

Ruby SDKs have further added references requiring new middleware gems in FaradayClient during connection initialization shown below:

require 'faraday/http_cache'
require 'faraday/retry'
require 'faraday/multipart'
require 'faraday/follow_redirects'
require 'faraday/gzip'
# Method to initialize the connection.
def create_connection(timeout:, max_retries:, retry_interval:,
backoff_factor:, retry_statuses:, retry_methods:,
cache: false, verify: true) do |faraday|
faraday.use Faraday::HttpCache, serializer: Marshal if cache
faraday.use Faraday::FollowRedirects::Middleware
faraday.request :gzip
faraday.request :multipart
faraday.request :url_encoded
faraday.ssl[:ca_file] = Certifi.where
faraday.ssl[:verify] = verify
faraday.request :retry, max: max_retries, interval: retry_interval,
backoff_factor: backoff_factor,
retry_statuses: retry_statuses,
methods: retry_methods,
retry_if: proc { |env, _exc|
env.request.context['forced_retry'] ||= false
faraday.adapter Faraday.default_adapter
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
faraday.options[:timeout] = timeout if timeout.positive?