Skip to content

Incompatibility with rubyzip 3.0 - Zlib::BufError on pass generation #93

@kjanoudi

Description

@kjanoudi

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|
  # ...
end

Rubyzip 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
end

Suggested 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
end

Or 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions