{"record":{"id":"4c1d1c3204fa5a81","repo":"HMCL-dev/HMCL","slug":"cannot-install-terracotta-s-system-installer-exi","errorCode":null,"errorMessage":"Cannot install Terracotta %s: system installer exited with code %d","messagePattern":"Cannot install Terracotta (.+?): system installer exited with code (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/terracotta/provider/MacOSProvider.java","lineNumber":83,"sourceCode":"            Files.copy(installer, movedInstaller, StandardCopyOption.REPLACE_EXISTING);\n\n            ManagedProcess process = new ManagedProcess(new ProcessBuilder(\n                    osascript.toString(), \"-e\", String.format(\n                    \"do shell script \\\"installer -pkg '%s' -target /\\\" with prompt \\\"%s\\\" with administrator privileges\",\n                    movedInstaller, i18n(\"terracotta.sudo_installing\")\n            )));\n            process.pumpInputStream(SystemUtils::onLogLine);\n            process.pumpErrorStream(SystemUtils::onLogLine);\n\n            return Task.fromCompletableFuture(process.getProcess().onExit()).thenRunAsync(() -> {\n                try {\n                    FileUtils.cleanDirectory(movedInstaller.getParent());\n                } catch (IOException e) {\n                    LOG.warning(\"Cannot remove temporary Terracotta package file.\", e);\n                }\n\n                if (process.getExitCode() != 0) {\n                    throw new IllegalStateException(String.format(\n                            \"Cannot install Terracotta %s: system installer exited with code %d\", movedInstaller, process.getExitCode()\n                    ));\n                }\n            });\n        });\n    }\n\n    @Override\n    public List<String> ofCommandLine(Path path) {\n        return List.of(executable.toString(), \"--hmcl\", path.toString());\n    }\n}\n","sourceCodeStart":65,"sourceCodeEnd":96,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/terracotta/provider/MacOSProvider.java#L65-L96","documentation":"Raised in MacOSProvider.install() when the macOS system 'installer' utility (invoked through osascript with administrator privileges) exits non-zero, meaning the Terracotta .pkg failed to install on the host system. This is a process-level failure: the package itself or the privileged installation step rejected or aborted, not a download or validation problem.","triggerScenarios":"Thrown at HMCL/src/main/java/org/jackhuang/hmcl/terracotta/provider/MacOSProvider.java:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the ManagedProcess log output for the installer's exit reason (e.g. damaged package, insufficient disk space, permission denial on the osascript prompt).","Re-download or re-export the Terracotta .pkg and retry the installation.","Run 'sudo installer -pkg <pkg> -target /' manually in a terminal to see the installer's detailed error message."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}