Fixed #168. Rubyzip changed default behavior.#170
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #168 by disabling ZIP64 support in rubyzip to fix compatibility issues with file saving. Rubyzip 3.x changed its default behavior to enable ZIP64 by default, which causes problems with tools like pandoc that don't support ZIP64 for small files. The fix adds a global configuration setting to disable ZIP64 support.
- Adds global configuration
Zip.write_zip64_support = falseto disable ZIP64 - Includes explanatory comments about rubyzip 3.x default behavior change
- Aims to restore compatibility with readers that don't support ZIP64
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Disable ZIP64 support to maintain compatibility with version 0.9.1 and | ||
| # ensure compatibility with all readers. Rubyzip 3.x enables ZIP64 by default, | ||
| # but many readers (including pandoc) don't support it for small files. | ||
| Zip.write_zip64_support = false |
There was a problem hiding this comment.
Setting global Zip configuration in a library gem is problematic. This modifies global state for all code using rubyzip in the consuming application, potentially breaking other functionality that may need ZIP64 support.
Consider investigating per-operation ZIP64 configuration instead of global configuration. If rubyzip 3.x doesn't support per-operation configuration, consider:
- Documenting this global configuration change prominently in README and CHANGELOG
- Providing a configuration option that allows users to opt-in/out of this behavior
- Only setting this configuration in the
saveandstreammethods and restoring it afterwards
This approach would minimize side effects on other code while achieving the same compatibility goal.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
docx 0.10.0 autorise rubyzip 3.x qui active ZIP64 par défaut.
LibreOffice ne peut pas ouvrir les docx en format ZIP64, causant
l'échec silencieux de la conversion PDF ("source file could not
be loaded"). Verrouillage à docx ~> 0.8.0 (rubyzip 2.x).
Ref: ruby-docx/docx#170
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@satoryu - could I ask for some attention to this PR? It fixes something people still keep struggling with. |
PR #170 fixed #168 by setting Zip.write_zip64_support = false at the top level when docx is required. That mutates global rubyzip state for the whole host application, which can break other code that relies on ZIP64 (flagged by Copilot review on #170). Instead, disable ZIP64 only while writing in #save / #stream via a with_zip64_disabled helper that restores the previous global value in an ensure block, so other rubyzip users are unaffected. Adds regression specs asserting the setting is not leaked after saving/streaming, and a CHANGELOG entry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Scope ZIP64 disabling to save/stream (follow-up to #170)
|
Hi @abartov, sorry for the delayed response on this — and thank you for sending the PR! 🙏 I've merged your fix and just released it as part of the latest gem version, v0.10.1. It's now available on RubyGems. For more details, please see the release notes: https://github.com/ruby-docx/docx/releases/tag/v0.10.1 As a small follow-up, I scoped the Thanks again for catching and fixing this! |
The issue with file saving was that Rubyzip 3.x now saves ZIP64 by default. This is unexpected and unsupported by many tools, and best not to enable by default in docx.
I'd appreciate it if the maintainers merge this and release a new gem.