{"record":{"id":"da807f1a1b4cf296","repo":"astral-sh/ruff","slug":"workspace-uri-is-not-a-file-or-directory-uri","errorCode":null,"errorMessage":"Workspace URI is not a file or directory: {uri:?}","messagePattern":"Workspace URI is not a file or directory: (.+?)","errorType":"error_code","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/ty_server/src/session.rs","lineNumber":1667,"sourceCode":"}\n\nimpl Workspaces {\n    /// Registers a new workspace with the given URI and default settings for the workspace.\n    ///\n    /// This returns `true` when this workspace is added and `false`\n    /// when it has already been added.\n    ///\n    /// It's the caller's responsibility to later call\n    /// [`Session::request_uninitialized_workspace_folder_configurations`] with\n    /// the resolved settings for this workspace. Registering and initializing\n    /// a workspace is a two-step process because the workspace are announced\n    /// to the server during the `initialize` request, but the resolved\n    /// settings are only available after the client has responded to the\n    /// `workspace/configuration` request.\n    fn register(&mut self, uri: Uri) -> anyhow::Result<bool> {\n        let path = uri\n            .to_file_path()\n            .map_err(|()| anyhow!(\"Workspace URI is not a file or directory: {uri:?}\"))?;\n\n        // Realistically I don't think this can fail because we got the path from a Uri\n        let system_path = SystemPathBuf::from_path_buf(path)\n            .map_err(|_| anyhow!(\"Workspace URI is not valid UTF8\"))?;\n\n        if self.workspaces.contains_key(&system_path) {\n            return Ok(false);\n        }\n\n        self.workspaces.insert(\n            system_path,\n            Workspace {\n                uri,\n                settings: Arc::new(WorkspaceSettings::default()),\n                initialized: false,\n            },\n        );\n        Ok(true)","sourceCodeStart":1649,"sourceCodeEnd":1685,"githubUrl":"https://github.com/astral-sh/ruff/blob/5bb508f59481c1a02d5c7ff8568b9ffd8a763eef/crates/ty_server/src/session.rs#L1649-L1685","documentation":"An anyhow error raised while registering a workspace: the client-supplied URI is neither a file nor a directory URI scheme ty can map to a filesystem path (for example a non-file scheme). The workspace cannot be created from it.","triggerScenarios":"Thrown at crates/ty_server/src/session.rs:1750 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send workspace folders with file:// URIs","Skip registration for URI schemes ty does not support"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5bb508f59481c1a02d5c7ff8568b9ffd8a763eef","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}