denoland/deno · error

Scope '{}' was not a directory path.

Error message

Scope '{}' was not a directory path.

What it means

In the Deno LSP (cli/lsp/config.rs:1487), every workspace scope key from deno.scopes / workspace configuration must convert to a local directory path via Url::to_file_path(). When that conversion fails — the URL is not a file:// URL or is structurally not a directory-path URL — ConfigData::load returns "Scope '{}' was not a directory path." and configuration for that scope is rejected.

Source

Thrown at cli/lsp/config.rs:1487

            None => {
              deno_config::workspace::WorkspaceDiscoverStart::Paths(&paths)
            }
          },
          &WorkspaceDiscoverOptions {
            additional_config_file_names: &[],
            deno_json_cache: Some(deno_json_cache),
            pkg_json_cache: Some(pkg_json_cache),
            workspace_cache: Some(workspace_cache),
            discover_pkg_json: !has_flag_env_var(
              &CliSys::default(),
              "DENO_NO_PACKAGE_JSON",
            ),
            maybe_vendor_override: None,
          },
        )
        .map_err(AnyError::from)
      }
      Err(()) => Err(anyhow!("Scope '{}' was not a directory path.", scope)),
    };
    match discover_result {
      Ok(member_dir) => {
        Self::load_inner(
          member_dir,
          scope,
          settings,
          Some(file_fetcher),
          Some(http_client_provider),
          ws_data_cache,
        )
        .await
      }
      Err(err) => {
        lsp_warn!("  Couldn't open workspace \"{}\": {}", scope.as_str(), err);
        let member_dir =
          WorkspaceDirectory::empty(WorkspaceDirectoryEmptyOptions {
            root_dir: scope.clone(),

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Use absolute file:// URLs that end with a slash for directories: "file:///home/me/project/"
  2. Fix or remove non-file scope keys (https:, untitled:, plain paths) from deno.scopes and deno.testing scopes in VS Code settings
  3. Reopen the folder as a local (file-scheme) workspace folder instead of a remote scheme so the LSP can map it

Example fix

// before (.vscode/settings.json)
"deno": { "scopes": { "file:///home/me/proj/src": { "unstable": true } } }

// after
"deno": { "scopes": { "file:///home/me/proj/src/": { "unstable": true } } }
Defensive patterns

Strategy: validation

Validate before calling

// Validate editor settings before the LSP reads them
function validateScopes(scopes) {
  for (const key of Object.keys(scopes)) {
    const u = new URL(key);
    if (u.protocol !== "file:" || !key.endsWith("/")) {
      console.error(`bad scope '${key}': must be a file:// URL ending with '/'`);
      return false;
    }
  }
  return true;
}

Type guard

function isDirectoryFileUrl(s: string): s is `file:///${string}/` {
  try {
    const u = new URL(s);
    return u.protocol === "file:" && s.endsWith("/");
  } catch {
    return false;
  }
}

Prevention

When it happens

Trigger: Putting a non-file scope key in settings, e.g. "deno": { "scopes": { "https://example.com/mod": {} } }; a VS Code multi-root folder backed by a remote/untitled scheme; a file URL that omits the trailing slash and encodes a file rather than a directory; malformed URL keys.

Common situations: Hand-editing .vscode/settings.json scopes after the auto-generated entries; SSH/remote or live-share workspace folders whose scheme isn't file:; scope keys written as plain paths (/home/me/proj) instead of file:///home/me/proj/.

Related errors


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/ee7391008ed9ace7. Report an issue: GitHub.