HMCL-dev/HMCL · error · IOException
Cannot parse the version of
Error message
Cannot parse the version of
What it means
Thrown while exporting a MultiMC modpack when the instance's game version cannot be determined (GameVersionNumber.unknown()). The MultiMC mmc-pack.json must include a net.minecraft component with an explicit version.
Solutions
- Set the correct game version in the HMCL instance settings before exporting
- Restore the instance's versions/<version>/version.json metadata
- Reinstall the game files for the instance, then retry the export
Example fix
// before GameVersionNumber version = instance.getVersion(); // unknown() -> IOException // after // configure instance game version (e.g. 1.20.1) in HMCL settings GameVersionNumber version = instance.getVersion(); // resolves zip.putDirectory(...); // export proceeds
Defensive patterns
Strategy: validation
Validate before calling
if (instance.getVersion() == GameVersionNumber.unknown()) throw new IOException("Cannot parse the version of " + instanceId); Type guard
boolean exportable(DefaultGameRepository repo, String id) { return repo.getGameVersion(id).isPresent(); } Try / catch
try { exportTask.execute(); } catch (IOException e) { /* fix instance version then retry */ } Prevention
- Set the game version in instance settings before export
- Keep version metadata files intact
- Test getVersion() resolves before running export tasks
When it happens
Trigger: Calling MultiMCModpackExportTask.execute() on an instance whose version metadata is missing or unparseable.
Common situations: Exporting broken or hand-built instances; instances whose version.json was deleted; instances installed from non-standard sources.
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
- mmc-pack.json malformed.
- Theme-pack asset source is not a regular file:
- Asset index file malformed
- Bad exit code
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/4bc164e7e3e3665a.
Report an issue: GitHub.
Appendix: source
Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/multimc/MultiMCModpackExportTask.java:93
}
}
});
}
/// {@inheritDoc}
@Override
public void execute() throws Exception {
var instanceId = instance.getId();
ArrayList<String> blackList = new ArrayList<>(ModAdviser.MODPACK_BLACK_LIST);
blackList.add(instanceId + ".jar");
blackList.add(instanceId + ".json");
LOG.info("Compressing game files without some files in blacklist, including files or directories: usernamecache.json, asm, logs, backups, versions, assets, usercache.json, libraries, crash-reports, launcher_profiles.json, NVIDIA, TCNodeTracker");
try (Zipper zip = new Zipper(output)) {
zip.putDirectory(instance.getRunDirectory(), ".minecraft", path -> Modpack.acceptFile(path, blackList, whitelist));
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();
List<MultiMCManifest.MultiMCManifestComponent> components = new ArrayList<>();
components.add(new MultiMCManifest.MultiMCManifestComponent(true, false, MultiMCComponents.getComponent(GameComponentType.GAME), gameVersion));
for (Map.Entry<String, GameComponentType> pair : MultiMCComponents.getPairs()) {
if (pair.getValue().isModLoader()) {
String componentVersion = analyzer.getVersion(pair.getValue());
if (componentVersion != null) {
components.add(new MultiMCManifest.MultiMCManifestComponent(false, false, pair.getKey(), componentVersion));
}
}
}
MultiMCManifest mmcPack = new MultiMCManifest(1, components);
zip.putTextFile(JsonUtils.GSON.toJson(mmcPack), "mmc-pack.json");
View on GitHub (pinned to 24702dc5a0)