astral-sh/ruff · error · anyhow::Error

Tried to remove non-existent workspace URI {workspace_uri}

Error message

Tried to remove non-existent workspace URI {workspace_uri}

What it means

Error "Tried to remove non-existent workspace URI {workspace_uri}" thrown in astral-sh/ruff.

Source

Thrown at crates/ruff_server/src/session/index.rs:193

    pub(super) fn open_workspace_folder(
        &mut self,
        uri: Uri,
        global: &GlobalClientSettings,
        client: &Client,
    ) -> crate::Result<()> {
        // TODO(jane): Find a way for workspace client settings to be added or changed dynamically.
        self.settings
            .register_workspace(&Workspace::new(uri), global, client)
    }

    pub(super) fn close_workspace_folder(&mut self, workspace_uri: &Uri) -> crate::Result<()> {
        let workspace_path = workspace_uri.to_file_path().map_err(|()| {
            anyhow!("Failed to convert workspace URI to file path: {workspace_uri}")
        })?;

        self.settings
            .remove(&workspace_path)
            .ok_or_else(|| anyhow!("Tried to remove non-existent workspace URI {workspace_uri}"))?;

        // O(n) complexity, which isn't ideal... but this is an uncommon operation.
        self.documents
            .retain(|uri, _| !Path::new(uri.path()).starts_with(&workspace_path));
        self.notebook_cells
            .retain(|_, uri| !Path::new(uri.path()).starts_with(&workspace_path));

        Ok(())
    }

    pub(super) fn make_document_ref(
        &self,
        key: DocumentKey,
        global: &GlobalClientSettings,
    ) -> Option<DocumentQuery> {
        let uri = self.uri_for_key(&key)?.clone();

        let document_settings = self

View on GitHub (pinned to 672bb4edf0)

When it happens

Trigger: Thrown at crates/ruff_server/src/session/index.rs:193 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16). Data as JSON: /api/errors/e9ec3d851c9b83b2. Report an issue: GitHub.