{"record":{"id":"9bb337138b0659e5","repo":"clockworklabs/SpacetimeDB","slug":"version-already-exists","errorCode":null,"errorMessage":"version already exists","messagePattern":"version already exists","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/paths/src/cli.rs","lineNumber":82,"sourceCode":"                        entry.file_name().into_string().ok().map(Ok)\n                    }\n                }\n                Err(e) => Some(Err(e.into())),\n            })\n            .collect()\n    }\n}\n\npath_type!(VersionBinDir: dir);\n\nimpl VersionBinDir {\n    pub fn spacetimedb_cli(self) -> SpacetimedbCliBin {\n        SpacetimedbCliBin(self.0.joined(\"spacetimedb-cli\").with_exe_ext())\n    }\n\n    pub fn create_custom(&self, path: &Path) -> anyhow::Result<()> {\n        if std::fs::symlink_metadata(self).is_ok_and(|m| m.file_type().is_dir()) {\n            anyhow::bail!(\"version already exists\");\n        }\n        self.link_to(path)\n    }\n\n    fn link_to(&self, path: &Path) -> anyhow::Result<()> {\n        let rel_path = path.strip_prefix(self.0.parent().unwrap()).unwrap_or(path);\n        #[cfg(unix)]\n        {\n            // remove the link if it already exists\n            std::fs::remove_file(self).ok();\n            std::os::unix::fs::symlink(rel_path, self)?;\n        }\n        #[cfg(windows)]\n        {\n            junction::delete(self).ok();\n            std::fs::remove_dir(self).ok();\n            // We won't be able to create a junction if the fs isn't NTFS, so fall back to trying\n            // to make a symlink.","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/paths/src/cli.rs#L64-L100","documentation":"The CLI version manager stores each installed version under its own bin directory. create_custom() links a custom binary into a version directory; if symlink_metadata shows a directory already exists at that path, it refuses to overwrite and bails.","triggerScenarios":"Running the custom-version link subcommand (crates/update/src/cli/link.rs calls create_custom) for a version label whose bin directory already exists on disk.","commonSituations":"Re-linking a custom build under the same version label twice; leftover version directories after a failed or partial uninstall; switching between custom builds with identical labels.","solutions":["Uninstall the existing version first (spacetime version uninstall <version>, or remove the directory under the versions root).","Link the new build under a different, unique version label.","If the directory is stale debris from an interrupted install, delete it manually and re-run the link command."],"exampleFix":"# before\nspacetime-update link ./target/release/spacetimedb-cli v9.9.9-custom # -> version already exists\n\n# after\nspacetime version uninstall v9.9.9-custom\nspacetime-update link ./target/release/spacetimedb-cli v9.9.9-custom","handlingStrategy":"validation","validationCode":"# before linking a custom version, check the target dir:\nVERSIONS=$(spacetime data-dir)/versions  # adjust to your layout\n[ -d \"$VERSIONS/v9.9.9-custom/bin\" ] && echo \"exists -> uninstall first\" || echo \"safe to link\"","typeGuard":null,"tryCatchPattern":"match link_custom_version(&path, &label) {\n    Err(e) if e.to_string() == \"version already exists\" => {\n        uninstall_version(&label)?; // then retry the link once\n        link_custom_version(&path, &label)\n    }\n    other => other,\n}","preventionTips":["Use unique version labels per build (include the commit hash).","Uninstall before re-linking the same label.","Clean up leftover version directories after failed installs."],"tags":["cli","version-manager","filesystem","install"],"backgroundTag":"path-already-exists","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}