HMCL-dev/HMCL · error · IOException
Cannot parse the version of
Error message
Cannot parse the version of
What it means
Thrown while exporting a Modrinth modpack when HMCL cannot determine the instance's game version (instance.getVersion() returns GameVersionNumber.unknown()). A Modrinth manifest requires an explicit Minecraft version in dependencies.
Solutions
- Set the instance's game version correctly in HMCL instance settings so getVersion() resolves
- Verify versions/<version>/version.json exists and is valid inside the instance directory
- Re-download/reinstall the instance's game files before exporting
Example fix
// before // exporting an instance with unresolvable version GameVersionNumber version = instance.getVersion(); // unknown() // after // fix instance settings (game version = 1.20.1) then export GameVersionNumber version = instance.getVersion(); // resolves to 1.20.1
Defensive patterns
Strategy: validation
Validate before calling
if (instance.getVersion() == GameVersionNumber.unknown()) throw new IOException("Cannot parse the version of " + instanceId); Type guard
boolean versionKnown(DefaultGameRepository repo, String id) { return repo.getGameVersion(id).isPresent(); } Try / catch
try { exportTask.execute(); } catch (IOException e) { /* ask user to fix instance version settings */ } Prevention
- Verify instance game version is set before exporting
- Keep versions/<v>/version.json intact in the instance directory
When it happens
Trigger: Calling ModrinthModpackExportTask.execute() on an instance whose version cannot be inferred, e.g. no version.json/game jar metadata or an isolated/unknown instance.
Common situations: Exporting a broken or manually assembled instance; instances missing their version metadata; very old or modified game directories.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Cannot parse the version of
- Theme-pack asset source is not a regular file:
- Asset index file malformed
- Bad exit code
- Cannot export a background directory as a theme-pack asset
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/6b8a479420e77c29.
Report an issue: GitHub.
Appendix: source
Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/modrinth/ModrinthModpackExportTask.java:199
}
} catch (IOException e) {
LOG.warning("Failed to process file: " + file, e);
}
});
}
}
zip.putDirectory(runDirectory, "client-overrides", path -> {
String relativePath = path.replace(File.separatorChar, '/');
if (filesInManifest.contains(relativePath)) {
return false;
}
return Modpack.acceptFile(path, blackList, info.getWhitelist());
});
GameVersionNumber version = instance.getVersion();
if (version == GameVersionNumber.unknown()) {
throw new IOException("Cannot parse the version of " + instanceId);
}
String gameVersion = version.toString();
GameComponentAnalyzer analyzer = instance.getAnalyzer();
Map<String, String> dependencies = new HashMap<>();
dependencies.put("minecraft", gameVersion);
Optional.ofNullable(analyzer.getVersion(GameComponentType.FORGE)).ifPresent(forgeVersion ->
dependencies.put("forge", forgeVersion));
Optional.ofNullable(analyzer.getVersion(GameComponentType.NEO_FORGE)).ifPresent(neoForgeVersion ->
dependencies.put("neoforge", neoForgeVersion));
Optional.ofNullable(analyzer.getVersion(GameComponentType.FABRIC)).ifPresent(fabricVersion ->
dependencies.put("fabric-loader", fabricVersion));
Optional.ofNullable(analyzer.getVersion(GameComponentType.QUILT)).ifPresent(quiltVersion ->
dependencies.put("quilt-loader", quiltVersion));
ModrinthManifest manifest = new ModrinthManifest(
"minecraft",View on GitHub (pinned to 24702dc5a0)