Search code examples
ruby-on-railsrubyrubygemsruby-on-rails-5

NoMethodError: undefined method `dependency' for Gzip:Class


I am running into a weird issue after trying to restart my official Redmine 4.2.3 docker container which is using ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux].

I have been running a plugin I wrote that uses the quickbooks-ruby gem found here for years without issues, however now I'm getting the following error:

 NoMethodError: undefined method `dependency' for Gzip:Class
/usr/local/bundle/gems/quickbooks-ruby-1.0.19/lib/quickbooks/faraday/middleware/gzip.rb:15:in `<class:Gzip>'
/usr/local/bundle/gems/quickbooks-ruby-1.0.19/lib/quickbooks/faraday/middleware/gzip.rb:14:in `<top (required)>'
/usr/local/bundle/gems/quickbooks-ruby-1.0.19/lib/quickbooks-ruby.rb:16:in `require'
/usr/local/bundle/gems/quickbooks-ruby-1.0.19/lib/quickbooks-ruby.rb:16:in `<top (required)>'
/usr/src/redmine/config/application.rb:18:in `<top (required)>'
/usr/src/redmine/Rakefile:5:in `<top (required)>'
/usr/local/bundle/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)

Here is the first 15 lines from /lib/quickbooks/faraday/middleware/gzip.rb

# https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/gzip.rb

require 'faraday'

# Middleware to automatically decompress response bodies. If the
# "Accept-Encoding" header wasn't set in the request, this sets it to
# "gzip,deflate" and appropriately handles the compressed response from the
# server. This resembles what Ruby 1.9+ does internally in Net::HTTP#get.
#
# This middleware is NOT necessary when these adapters are used:
# - net_http on Ruby 1.9+
# - net_http_persistent on Ruby 2.0+
# - em_http
class Gzip < Faraday::Middleware
  dependency 'zlib' 

It seems my issue is with the dependency declaration, and I'm not quite sure how to fix this.

Please advise & Thank you in advance -ricky


Solution

  • It looks like quickbooks-ruby is dependent on faraday_middleware:1.2.0,. Nothing specifies this, so faraday:2.x.x is installed instead. To fix this, you can try adding

    gem 'faraday_middleware', '1.2.0'
    

    to your redmine_qbo Gemfile.