NoMethodError: undefined method `dependency' for Gzip:Class

NoMethodError: undefined method `dependency' for Gzip:Class

在尝试重启我的官方 Redmine 4.2.3 docker 容器后,我 运行 遇到了一个奇怪的问题,该容器使用 ruby 2.7.5p203(2021-11-24 修订版) f69aeb8314) [x86_64-linux].

多年来我一直运行一个plugin I wrote that uses the quickbooks-ruby gem found here没有问题,但是现在我收到以下错误:

 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)

这是 /lib/quickbooks/faraday/middleware/gzip.rb

的前 15 行
# 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' 

看来我的问题是 dependency 声明,我不太确定如何解决这个问题。

请提前告知&谢谢 -瑞奇

看起来 quickbooks-ruby 依赖于 faraday_middleware:1.2.0,.没有指定这一点,因此安装了 faraday:2.x.x。要解决此问题,您可以尝试添加

gem 'faraday_middleware', '1.2.0'

到您的 redmine_qbo Gemfile。