HMCL-dev/HMCL · error · IllegalArgumentException

Instance is not a Curse modpack. Cannot update this…

Error message

Instance  is not a Curse modpack. Cannot update this instance.

What it means

CurseInstallTask's constructor throws IllegalArgumentException when an update (updateTarget != null) is requested for an instance that has no Curse modpack configuration file on disk. Updating only makes sense for instances originally installed from a Curse modpack.

Solutions

  1. Reinstall the modpack fresh instead of using the update path
  2. Verify the instance was originally installed as a Curse modpack (modpack configuration file present)
  3. Point the update at the correct instance ID that contains the Curse configuration

Example fix

// before
new CurseInstallTask(dependencyManager, profile, someVanillaInstanceId, null, version, updateTarget); // updateTarget set, no config file
// after
new CurseInstallTask(dependencyManager, profile, curseInstanceId, null, version, null); // fresh install, or use the actual Curse instance ID
Defensive patterns

Strategy: validation

Validate before calling

Path json = repository.getLayout().getModpackConfigurationFile(instanceId);
if (updateTarget != null && Files.notExists(json)) { /* refuse to update: not a modpack instance */ }

Type guard

boolean isCurseInstance(GameRepository repo, String id) { return Files.exists(repo.getLayout().getModpackConfigurationFile(id)); }

Try / catch

try { new CurseInstallTask(...); } catch (IllegalArgumentException e) { /* fall back to fresh install */ }

Prevention

When it happens

Trigger: Creating a CurseInstallTask with a non-null updateTarget for an instanceId whose getModpackConfigurationFile(instanceId) JSON does not exist (Files.notExists).

Common situations: Pointing an update at an instance installed from a plain zip/vanilla install or from a different modpack provider (Mcbbs, etc.), or the user deleted modpack.json from the instance root.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10). Data as JSON: /api/errors/937b7a3cdcac5487. Report an issue: GitHub.

Appendix: source

Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/curse/CurseInstallTask.java:147

            Modpack modpack,
            CurseManifest manifest,
            GameInstanceID instanceId,
            @Nullable DefaultGameInstance updateTarget,
            @Nullable String iconUrl) {
        this.dependencyManager = dependencyManager;
        this.zipFile = zipFile;
        this.modpack = modpack;
        this.manifest = manifest;
        this.instanceId = instanceId;
        this.updateTarget = updateTarget;
        this.iconUrl = iconUrl;
        this.repository = dependencyManager.getGameRepository();

        this.run = repository.getLayout().getInstanceRoot(instanceId);

        Path json = repository.getLayout().getModpackConfigurationFile(instanceId);
        if (this.updateTarget != null && Files.notExists(json))
            throw new IllegalArgumentException("Instance " + instanceId + " is not a Curse modpack. Cannot update this instance.");

        @Nullable ModpackConfiguration<CurseManifest> config = null;
        try {
            if (this.updateTarget != null && Files.exists(json)) {
                config = JsonUtils.fromJsonFile(json, ModpackConfiguration.typeOf(CurseManifest.class));

                if (config == null || !CurseModpackProvider.INSTANCE.getName().equals(config.getType()))
                    throw new IllegalArgumentException("Instance " + instanceId + " is not a Curse modpack. Cannot update this instance.");
            }
        } catch (JsonParseException | IOException ignore) {
        }
        this.config = config;

        onDone().register(event -> {
            @Nullable Exception ex = event.getTask().getException();
            if (this.updateTarget == null && event.isFailed()) {
                if (!(ex instanceof ModpackCompletionException)) {
                    repository.removeInstanceFromDisk(instanceId);

View on GitHub (pinned to 24702dc5a0)