HMCL-dev/HMCL · error · IllegalStateException

Game instance no longer exists:

Error message

Game instance no longer exists: 

What it means

In update mode the target instance must still exist when the task runs. preExecute checks the draft's base snapshot and throws if the instance recorded at construction time has disappeared, since there is nothing to update.

Solutions

  1. Reinstall the modpack as a new installation instead of updating.
  2. Re-check instance existence before constructing/running the update task.
  3. Refresh the instance list so stale references are dropped.

Example fix

// before
task = new MultiMCModpackInstallTask(dm, zip, modpack, cfg, staleInstance);
// after
if (repository.hasInstance(staleInstance.getId())) {
    task = new MultiMCModpackInstallTask(dm, zip, modpack, cfg, staleInstance);
} else {
    task = new MultiMCModpackInstallTask(dm, zip, modpack, cfg, staleInstance.getId()); // fresh install
}
Defensive patterns

Strategy: validation

Validate before calling

if (!repository.hasInstance(instance.getId())) { /* refresh UI / fall back to fresh install */ }

Try / catch

try { task.run(); } catch (IllegalStateException e) { if (e.getMessage().startsWith("Game instance no longer exists")) { /* reinstall fresh */ } }

Prevention

When it happens

Trigger: Update-mode task executed after the target instance was deleted from disk (manually, by another task, or by a failed prior update) so baseSnapshot.hasInstance(instanceId) returns false.

Common situations: User deletes the instance while an update is queued; an earlier failed install removed the instance from disk but the UI still holds a stale reference.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/multimc/MultiMCModpackInstallTask.java:186

    @Override
    public boolean doPreExecute() {
        return true;
    }

    /// Reserves the instance in a repository draft before preparing tasks that write its root.
    @Override
    public void preExecute() throws Exception {
        DefaultGameRepositoryDraft openedDraft = repository.openDraft();
        draft = openedDraft;
        try {
            // Construction fixes the mode; the captured snapshot only verifies that it is still valid.
            boolean targetExists = openedDraft.getBaseSnapshot().hasInstance(instanceId);
            if (this.updateTarget == null && targetExists) {
                throw new IllegalStateException("Game instance already exists: " + instanceId);
            }
            if (this.updateTarget != null && !targetExists) {
                throw new IllegalStateException("Game instance no longer exists: " + instanceId);
            }

            openedDraft.put(new GameInstanceManifest(instanceId));
            newInstallationReserved = this.updateTarget == null;
        } catch (IOException | RuntimeException e) {
            try {
                openedDraft.abort();
            } catch (IOException cleanupFailure) {
                e.addSuppressed(cleanupFailure);
            }
            draft = null;
            throw e;
        }

        // Stage #0: General Setup
        {
            Path run = repository.getLayout().getInstanceRoot(instanceId);

View on GitHub (pinned to 24702dc5a0)