{"record":{"id":"ad2ac54bd732da0b","repo":"astral-sh/ruff","slug":"uv-was-not-found-is-it-installed-and-on-the-path","errorCode":null,"errorMessage":"uv was not found; is it installed and on the PATH?","messagePattern":"uv was not found; is it installed and on the PATH\\?","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_server/src/format.rs","lineNumber":315,"sourceCode":"        command.stdout(Stdio::piped());\n        command.stderr(Stdio::piped());\n\n        command\n    }\n\n    /// Execute the format command on the given source.\n    fn format(\n        &self,\n        source: &str,\n        path: &Path,\n        range_with_index: Option<(TextRange, &LineIndex)>,\n    ) -> crate::Result<FormatResult> {\n        let mut command =\n            self.build_command(path, range_with_index.map(|(r, idx)| (r, idx, source)));\n        let mut child = match command.spawn() {\n            Ok(child) => child,\n            Err(err) if err.kind() == std::io::ErrorKind::NotFound => {\n                anyhow::bail!(\"uv was not found; is it installed and on the PATH?\")\n            }\n            Err(err) => return Err(err).context(\"Failed to spawn uv\"),\n        };\n\n        let mut stdin = child\n            .stdin\n            .take()\n            .context(\"Failed to get stdin from format subprocess\")?;\n        stdin\n            .write_all(source.as_bytes())\n            .context(\"Failed to write to stdin\")?;\n        drop(stdin);\n\n        let result = child\n            .wait_with_output()\n            .context(\"Failed to get output from format subprocess\")?;\n\n        if !result.status.success() {","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_server/src/format.rs#L297-L333","documentation":"The Ruff language server delegates `uv format` for document/range formatting by spawning a `uv` subprocess. If spawning fails with `ErrorKind::NotFound`, the server bails with this anyhow error explaining that `uv` is not installed or not on the PATH.","triggerScenarios":"Triggering format-on-save or a manual `textDocument/formatting`/`rangeFormatting` request while the `uv` executable cannot be found on the system PATH used by the server process.","commonSituations":"uv not installed at all; uv installed via a tool manager (e.g. pipx, cargo) whose bin dir isn't on the server's PATH; launching the editor from a GUI where PATH differs from the shell; wrong interpreter/environment for the LSP process.","solutions":["Install uv (e.g. `curl -LsSf https://astral.sh/uv/install.sh | sh` or `pip install uv`)","Verify with `which uv` / `where uv` that uv resolves on the PATH of the process that launched the editor","Configure the server's environment (e.g. `ruff.server.environment` or launcher env) to include uv's bin directory, then restart the editor"],"exampleFix":"# before (uv not on PATH)\n# $ which uv\n# uv not found\n# after\ncurl -LsSf https://astral.sh/uv/install.sh | sh\nexport PATH=\"$HOME/.local/bin:$PATH\"  # then restart the editor","handlingStrategy":"fallback","validationCode":"import shutil\nif shutil.which('uv') is None:\n    raise SystemExit(\"uv was not found; install it or add it to PATH before using LSP formatting\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install uv and confirm `which uv` works in the editor's environment","Launch the editor from a shell with the correct PATH or configure the server env","Pin uv in dev setup docs so team machines have it","Use format-on-save only after verifying uv availability"],"tags":["ruff","lsp","formatting","uv","path"],"backgroundTag":"executable-not-found-in-path","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}