{"record":{"id":"d58edcb0464048cf","repo":"zed-industries/zed","slug":"extension-dir-is-not-an-absolute-path","errorCode":null,"errorMessage":"extension dir {} is not an absolute path","messagePattern":"extension dir (.+?) is not an absolute path","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/extension/src/extension_builder.rs","lineNumber":104,"sourceCode":"        Self {\n            cache_dir,\n            http: http_client,\n        }\n    }\n\n    pub async fn compile_extension(\n        &self,\n        extension_dir: &Path,\n        extension_manifest: &mut ExtensionManifest,\n        options: CompileExtensionOptions,\n        fs: Arc<dyn Fs>,\n    ) -> Result<()> {\n        let start = std::time::Instant::now();\n\n        populate_defaults(extension_manifest, extension_dir, fs.clone()).await?;\n\n        if extension_dir.is_relative() {\n            bail!(\n                \"extension dir {} is not an absolute path\",\n                extension_dir.display()\n            );\n        }\n\n        fs.create_dir(&self.cache_dir)\n            .await\n            .context(\"failed to create cache dir\")?;\n\n        let (tx, mut rx) = oneshot::channel();\n\n        let clang_path = extension_manifest.grammars.is_empty().not().then(|| {\n            std::iter::repeat_n(\n                async {\n                    self.install_wasi_sdk_if_needed()\n                        .await\n                        .log_err()\n                        .map(Arc::new)","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/extension/src/extension_builder.rs#L86-L122","documentation":"ExtensionBuilder::compile_extension() requires the extension_dir argument to be an absolute path and bails with this message after populate_defaults when extension_dir.is_relative(). The builder later does extension_dir.join(...) for cargo target dirs, manifest paths and wasm output, and sets it as cargo's current_dir, so relative paths would resolve against an unpredictable working directory.","triggerScenarios":"Calling compile_extension(extension_dir, ...) with a path like \"my-extension\", \"./ext/foo\", or \"../foo\" - anything Path::is_relative() returns true for. Typical for programmatic users of the crates/extension builder API rather than the zed CLI (the CLI resolves its paths first).","commonSituations":"Scripts or CI code that passes the CLI argument straight through without canonicalization; tests using fixture-relative paths; switching code that worked under an assumed cwd to another launcher with a different working directory.","solutions":["Canonicalize before calling: let dir = std::fs::canonicalize(input_path)?; and pass &dir","Or build an absolute path from a known root: let dir = std::env::current_dir()?.join(input);","In tests, use absolute fixture paths (e.g. via CARGO_MANIFEST_DIR) rather than relative ones"],"exampleFix":"// before\nlet extension_dir = Path::new(\"extensions/my-ext\");\nbuilder.compile_extension(extension_dir, &mut manifest, options, fs).await?;\n\n// after\nlet extension_dir = std::fs::canonicalize(\"extensions/my-ext\")?;\nbuilder.compile_extension(&extension_dir, &mut manifest, options, fs).await?;","handlingStrategy":"validation","validationCode":"let extension_dir = std::fs::canonicalize(input_path)\n    .context(\"resolve extension dir to an absolute path\")?;\nanyhow::ensure!(\n    extension_dir.is_absolute(),\n    \"extension dir must be absolute: {}\",\n    input_path.display()\n);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Canonicalize user-supplied paths at your CLI boundary before calling builder APIs","In tests, derive fixture paths from env!(\"CARGO_MANIFEST_DIR\") so they are always absolute"],"tags":["zed","extension","path","validation","absolute-path"],"backgroundTag":"relative-path-rejected","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}