HMCL-dev/HMCL · error · IOException
Cannot parse the version of
Error message
Cannot parse the version of
What it means
Thrown during server modpack export when the game version of the instance being exported cannot be parsed into a GameVersionNumber. HMCL requires a concrete, resolvable Minecraft game version to embed as the 'game' addon in the exported manifest, so an unresolvable/unknown version makes export impossible.
Solutions
- Open the instance settings and set/repair a valid Minecraft game version before exporting.
- Reinstall or update the game component (game patch) so the version resolves correctly.
- Check instance version JSON files under the instance's 'hmclversion.cfg'/version patches for corruption and fix the version id.
- Export from a properly launched instance; launch once successfully so the version resolves, then retry export.
Example fix
// before: instance has no resolvable game version GameVersionNumber version = instance.getVersion(); // unknown() // after: repair version first, e.g. in instance settings set version to 1.20.1, then GameVersionNumber version = instance.getVersion(); // 1.20.1
Defensive patterns
Strategy: try-catch
Validate before calling
GameVersionNumber version = instance.getVersion();
if (version == null || version == GameVersionNumber.unknown())
return; // cannot export: repair instance version first Try / catch
try {
exportTask.execute();
} catch (IOException e) {
if (e.getMessage().startsWith("Cannot parse the version of ")) {
// prompt user to fix the instance's game version
}
} Prevention
- Ensure the instance launches successfully before exporting.
- Keep the game version patch intact; don't remove version components.
- Verify the instance shows a concrete game version in the UI before export.
When it happens
Trigger: ServerModpackExportTask.execute() calls instance.getVersion(), which returns GameVersionNumber.unknown() because the instance's game version cannot be resolved (e.g. missing or unparseable version in the instance config).
Common situations: Exporting a broken or partially installed instance; an instance whose game version was never set; custom instances with manipulated version JSON; snapshots/odd version strings the resolver cannot recognize.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Malformed modpack configuration:
- Unsupported icon file:
- Missing hmcl.lwjgl-unsafe-agent.version attribute
- Invalid library path:
- /assets/
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/414db0abe41000b8.
Report an issue: GitHub.
Appendix: source
Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/server/ServerModpackExportTask.java:103
try (Zipper zip = new Zipper(modpackFile)) {
Path runDirectory = instance.getRunDirectory();
List<ModpackConfiguration.FileInformation> files = new ArrayList<>();
zip.putDirectory(runDirectory, "overrides", path -> {
if (Modpack.acceptFile(path, blackList, exportInfo.getWhitelist())) {
Path file = runDirectory.resolve(path);
if (Files.isRegularFile(file)) {
String relativePath = runDirectory.relativize(file).normalize().toString().replace(File.separatorChar, '/');
files.add(new ModpackConfiguration.FileInformation(relativePath, DigestUtils.digestToString("SHA-1", file)));
}
return true;
} else {
return false;
}
});
GameVersionNumber version = instance.getVersion();
if (version == GameVersionNumber.unknown()) {
throw new IOException("Cannot parse the version of " + instanceId);
}
String gameVersion = version.toString();
List<ServerModpackManifest.Addon> addons = new ArrayList<>();
addons.add(new ServerModpackManifest.Addon(GameComponentType.GAME.getPatchId(), gameVersion));
for (GameComponentAnalyzer.Mark mark : instance.getAnalyzer()) {
if ((mark.componentType().isModLoader() || mark.componentType() == GameComponentType.OPTIFINE)
&& mark.version() != null) {
addons.add(new ServerModpackManifest.Addon(mark.componentType().getPatchId(), mark.version()));
}
}
ServerModpackManifest manifest = new ServerModpackManifest(exportInfo.getName(), exportInfo.getAuthor(), exportInfo.getVersion(), exportInfo.getDescription(), StringUtils.removeSuffix(exportInfo.getFileApi(), "/"), files, addons);
zip.putTextFile(JsonUtils.GSON.toJson(manifest), "server-manifest.json");
}
}
/// Export options supported by the server modpack format.View on GitHub (pinned to 24702dc5a0)