Issue: mrpack4server silently falls back to setup when local.mrpack cannot be opened by Java ZIP
Environment
- Windows 11 / Windows Server
- Java 17 (Azul Zulu 17)
- mrpack4server 0.5.0,
mrpack4server-0.5.0-jvm17.jar
- Modrinth
.mrpack file exported from a Chinese modpack, about 172 MB
Steps To Reproduce
- Create a server directory.
- Put
mrpack4server-0.5.0-jvm17.jar in the directory and rename it to server.jar.
- Put the
.mrpack file in the same directory and rename it to local.mrpack.
- Run:
java -jar server.jar nogui
Expected:
Starting installation of <modpack> (<version>)
Actual:
Couldn't find modpack definition! Creating a new one...
Provide modpack name, it's id or url linking to it.
Prefix with ? to search.
>
Root Cause
java.util.zip cannot open the .mrpack file:
java.util.zip.ZipException: invalid CEN header (bad entry name)
PowerShell/.NET can open the same file and read modrinth.index.json correctly, which suggests the ZIP central directory contains entry names that Java does not accept, likely because the exporter wrote non-UTF-8 or otherwise incompatible entry names.
In resolveModpackInfoExternal, the FileSystems.newFileSystem(possibleMrpack) failure is swallowed:
try (var zip = FileSystems.newFileSystem(possibleMrpack)) {
...
} catch (Throwable e) {
// ignored
}
As a result, mrpack4server treats the existing local.mrpack as missing and opens the interactive setup prompt.
Workaround
Rezip the same entries with a standard UTF-8 ZIP writer. For example, PowerShell can rewrite the archive without changing the file contents:
Add-Type -AssemblyName System.IO.Compression
Add-Type -AssemblyName System.IO.Compression.FileSystem
$src = "C:\path\to\local-original.mrpack"
$out = "C:\path\to\local-fixed.mrpack"
$sourceZip = [System.IO.Compression.ZipFile]::OpenRead($src)
$targetZip = [System.IO.Compression.ZipFile]::Open($out, [System.IO.Compression.ZipArchiveMode]::Create)
foreach ($entry in $sourceZip.Entries) {
$name = $entry.FullName.Replace('\', '/')
$newEntry = $targetZip.CreateEntry($name, [System.IO.Compression.CompressionLevel]::Optimal)
if (-not $entry.FullName.EndsWith('/')) {
$input = $entry.Open()
$output = $newEntry.Open()
try { $input.CopyTo($output) } finally { $output.Dispose(); $input.Dispose() }
} else {
$newEntry.Open().Dispose()
}
}
$targetZip.Dispose()
$sourceZip.Dispose()
After replacing local.mrpack with the fixed archive, mrpack4server detects it and installs the modpack normally.
Suggested Fix
- Do not swallow the underlying ZIP exception when
local.mrpack exists but cannot be opened.
- Log the exception and print a clear message such as:
Found local.mrpack but Java could not open it as a ZIP archive. Run `jar tf local.mrpack` for more details.
- Optionally attempt a repair path that re-writes the archive using a standard ZIP writer when Java's built-in ZIP reader rejects the entry names.
- Modrinth App and pack export tools should ensure
.mrpack ZIP entry names are valid UTF-8.
Repro Artifact
The original file is kept as local-original.mrpack; the fixed archive is local.mrpack in the user's server directory.
problem mrpack file:
https://cdn.bbsmc.net/bbsmc/data/YtS91hhr/versions/TR5ISmKg/FarmingTales_Forge%E2%85%A1%20v1.5.1.mrpack
Issue: mrpack4server silently falls back to setup when
local.mrpackcannot be opened by Java ZIPEnvironment
mrpack4server-0.5.0-jvm17.jar.mrpackfile exported from a Chinese modpack, about 172 MBSteps To Reproduce
mrpack4server-0.5.0-jvm17.jarin the directory and rename it toserver.jar..mrpackfile in the same directory and rename it tolocal.mrpack.java -jar server.jar noguiExpected:
Actual:
Root Cause
java.util.zipcannot open the.mrpackfile:PowerShell/.NET can open the same file and read
modrinth.index.jsoncorrectly, which suggests the ZIP central directory contains entry names that Java does not accept, likely because the exporter wrote non-UTF-8 or otherwise incompatible entry names.In
resolveModpackInfoExternal, theFileSystems.newFileSystem(possibleMrpack)failure is swallowed:As a result, mrpack4server treats the existing
local.mrpackas missing and opens the interactive setup prompt.Workaround
Rezip the same entries with a standard UTF-8 ZIP writer. For example, PowerShell can rewrite the archive without changing the file contents:
After replacing
local.mrpackwith the fixed archive, mrpack4server detects it and installs the modpack normally.Suggested Fix
local.mrpackexists but cannot be opened..mrpackZIP entry names are valid UTF-8.Repro Artifact
The original file is kept as
local-original.mrpack; the fixed archive islocal.mrpackin the user's server directory.problem mrpack file:
https://cdn.bbsmc.net/bbsmc/data/YtS91hhr/versions/TR5ISmKg/FarmingTales_Forge%E2%85%A1%20v1.5.1.mrpack