{"record":{"id":"51fe0471ca490acc","repo":"arduino/Arduino","slug":"platform-is-already-installed","errorCode":null,"errorMessage":"Platform is already installed!","messagePattern":"Platform is already installed!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java","lineNumber":76,"sourceCode":"import java.util.*;\nimport java.util.stream.Collectors;\n\nimport static processing.app.I18n.format;\nimport static processing.app.I18n.tr;\n\npublic class ContributionInstaller {\n  private final Platform platform;\n  private final SignatureVerifier signatureVerifier;\n\n  public ContributionInstaller(Platform platform, SignatureVerifier signatureVerifier) {\n    this.platform = platform;\n    this.signatureVerifier = signatureVerifier;\n  }\n\n  public synchronized List<String> install(ContributedPlatform contributedPlatform, ProgressListener progressListener) throws Exception {\n    List<String> errors = new LinkedList<>();\n    if (contributedPlatform.isInstalled()) {\n      throw new Exception(\"Platform is already installed!\");\n    }\n\n    // Do not download already installed tools\n    List<ContributedTool> tools = new ArrayList<>();\n    for (ContributedTool tool : contributedPlatform.getResolvedTools()) {\n      DownloadableContribution downloadable = tool.getDownloadableContribution(platform);\n      if (downloadable == null) {\n        throw new Exception(format(tr(\"Tool {0} is not available for your operating system.\"), tool.getName()));\n      }\n      // Download the tool if it's not installed or it's a built-in tool\n      if (!tool.isInstalled() || tool.isBuiltIn()) {\n        tools.add(tool);\n      }\n    }\n\n    DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.indexer.getStagingFolder());\n\n    // Calculate progress increases","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java#L58-L94","documentation":"ContributionInstaller.install() first checks contributedPlatform.isInstalled() and refuses to proceed if that platform is already installed. The guard prevents duplicate installations and corrupted state; it throws a plain Exception with this message.","triggerScenarios":"Calling install(contributedPlatform, progressListener) for a platform whose isInstalled() returns true — typically re-invoking install for a platform already present in the installed packages state.","commonSituations":"Automated scripts re-running an install step idempotently without checking state first; stale index after an install in the same session; version pinning code comparing only by name so an 'upgrade' attempt is seen as already-installed.","solutions":["Check contributedPlatform.isInstalled() before calling install(), or catch the Exception and treat it as a no-op.","To replace/upgrade, first call remove/reverse installation of the existing platform, then install the new version.","Refresh the package index and installed-state so isInstalled() reflects reality (e.g. after manual deletion of hardware folders).","Compare exact versions in your own code to distinguish 'same version installed' from 'newer version available'."],"exampleFix":"// before\ninstaller.install(platform, listener);\n// after\nif (!platform.isInstalled()) {\n  installer.install(platform, listener);\n}","handlingStrategy":"validation","validationCode":"if (platform.isInstalled()) { return Collections.emptyList(); } // already satisfied\ninstaller.install(platform, listener);","typeGuard":null,"tryCatchPattern":"try { installer.install(platform, listener); } catch (Exception e) { if (\"Platform is already installed!\".equals(e.getMessage())) { /* treat as success */ } else { throw e; } }","preventionTips":["Always check isInstalled() before install in scripts and UIs.","Make install steps idempotent by skipping satisfied platforms.","Explicitly remove an old version before installing a different one."],"tags":["arduino","packages","idempotency","installer"],"backgroundTag":"file-already-exists","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}