-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Description
The passbook gem (version 0.4.4) is incompatible with rubyzip 3.0, causing a Zlib::BufError when generating passes.
Error Details
When using rubyzip 3.0.1 with passbook 0.4.4, the following error occurs:
Zlib::BufError: buffer error
Stack trace points to passbook/pkpass.rb:100 where Zip::OutputStream.write_buffer is called.
Root Cause
Rubyzip 3.0 introduced breaking API changes. Specifically, Zip::OutputStream.write_buffer now requires named parameters:
Rubyzip 2.x (works):
Zip::OutputStream.write_buffer do |zip|
# ...
endRubyzip 3.x (current passbook code fails):
The method signature changed to:
def write_buffer(io = ::StringIO.new(''), encrypter: nil)Current passbook code
In lib/passbook/pkpass.rb:100:
def outputZip(manifest, signature)
Zip::OutputStream.write_buffer do |zip| # This fails with rubyzip 3.0
# ...
end
endSuggested Fix
Update the code to be compatible with both rubyzip 2.x and 3.x:
def outputZip(manifest, signature)
if Zip::VERSION.start_with?('3.')
Zip::OutputStream.write_buffer(::StringIO.new('')) do |zip|
# existing code
end
else
Zip::OutputStream.write_buffer do |zip|
# existing code
end
end
endOr simply update the gemspec to restrict rubyzip to < 3.0:
spec.add_runtime_dependency 'rubyzip', '>= 1.0.0', '< 3.0'Environment
- Ruby version: 3.4.4
- Passbook version: 0.4.4
- Rubyzip version: 3.0.1
Workaround
Currently, users need to explicitly pin rubyzip to version 2.x in their Gemfile:
gem 'rubyzip', '~> 2.3'References
Metadata
Metadata
Assignees
Labels
No labels