I’m struggling to get ZipArchives.jl and Mmap.jl to work together in the way I want - basically just following the docs.
MWE looks like this:
using ZipArchives
using Mmap
io=open("simpletest.zip")
mm=Mmap.mmap(io)
q = ZipArchives.ZipReader(mm)
readme_n_lines = zip_openentry(q, "xl/worksheets/sheet1.xml") do z
countlines(z)
end
close(io)
#GC.gc()
ZipArchives.ZipWriter("simpletest.zip") do w
zip_newfile(w, "test/test2.txt")
write(w, "I am data inside test2.txt in the zip file")
end
Which produces the following:
ERROR: LoadError: SystemError: opening file "simpletest.zip": Invalid argument
Stacktrace:
[1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
@ Base .\error.jl:176
[2] systemerror
@ .\error.jl:176
[3] systemerror
@ .\error.jl:175 [inlined]
[4] open(fname::String; lock::Bool, read::Nothing, write::Bool, create::Nothing, truncate::Nothing, append::Nothing)
@ Base .\iostream.jl:295
[5] open
@ .\iostream.jl:277 [inlined]
[6] #ZipWriter#17
@ C:\Users\tim\.julia\packages\ZipArchives\5fdTS\src\writer.jl:65 [inlined]
[7] ZipWriter(f::Function, filename::String)
@ ZipArchives C:\Users\tim\.julia\packages\ZipArchives\5fdTS\src\writer.jl:64
[8] top-level scope
@ c:\Users\tim\OneDrive\Documents\Julia\ZipArchives\TestMmap.jl:13
[9] include(fname::String)
@ Main .\sysimg.jl:38
[10] run(debug_session::VSCodeDebugger.DebugAdapter.DebugSession, error_handler::VSCodeDebugger.var"#3#4"{String})
@ VSCodeDebugger.DebugAdapter c:\Users\tim\.vscode\extensions\julialang.language-julia-1.144.2\scripts\packages\DebugAdapter\src\packagedef.jl:123
[11] startdebugger()
@ VSCodeDebugger c:\Users\tim\.vscode\extensions\julialang.language-julia-1.144.2\scripts\packages\VSCodeDebugger\src\VSCodeDebugger.jl:47
[12] top-level scope
@ c:\Users\tim\.vscode\extensions\julialang.language-julia-1.144.2\scripts\debugger\run_debugger.jl:12
[13] include(mod::Module, _path::String)
@ Base .\Base.jl:557
[14] exec_options(opts::Base.JLOptions)
@ Base .\client.jl:323
[15] _start()
@ Base .\client.jl:531
in expression starting at c:\Users\tim\OneDrive\Documents\Julia\ZipArchives\TestMmap.jl:13
I found this old thread, so I tried swapping the close
for a GC.gc()
or doing both (close
first) or doing neither. Every case resulted in the same error.
In this case, the zip file is a renamed Excel file but, to be honest, I don’t think the file content is causing this issue.
Am I doing something daft, or is there something awry in ZipArchives.jl?
Edit: to add:
pkg> st
Status `C:\Users\tim\OneDrive\Documents\Julia\ZipArchives\Project.toml`
[72c71f33] XML v0.3.5
[49080126] ZipArchives v2.4.1
[a63ad114] Mmap v1.11.0
julia> versioninfo()
Julia Version 1.11.5
Commit 760b2e5b73 (2025-04-14 06:53 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 24 × AMD Ryzen 9 9900X 12-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, generic)
Threads: 8 default, 0 interactive, 4 GC (on 24 virtual cores)
Environment:
JULIA_EDITOR = code
JULIA_VSCODE_REPL = 1
JULIA_NUM_THREADS = 8