{"record":{"id":"9a147b64ed8c2429","repo":"denoland/deno","slug":"could-not-determine-directory-of","errorCode":null,"errorMessage":"Could not determine directory of '{}'","messagePattern":"Could not determine directory of '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/pm/mod.rs","lineNumber":1473,"sourceCode":"      ConfigKind::DenoJson,\n      url_to_file_path(&deno_json.specifier)?,\n    )?,\n    None => bail!(\"No deno.json found; there are no linked packages to unlink\"),\n  };\n  Ok((cli_factory, deno_config))\n}\n\npub async fn link(\n  flags: Arc<Flags>,\n  link_flags: LinkFlags,\n) -> Result<(), AnyError> {\n  let (cli_factory, mut deno_config) = load_deno_config_for_link(&flags, true)?;\n  let cwd = cli_factory.cli_options()?.initial_cwd().to_path_buf();\n  let config_dir = deno_config\n    .path\n    .parent()\n    .ok_or_else(|| {\n      deno_core::anyhow::anyhow!(\n        \"Could not determine directory of '{}'\",\n        deno_config.path.display()\n      )\n    })?\n    .to_path_buf();\n\n  // Validate every path and compute the relative form we'll store.\n  let mut resolved = Vec::with_capacity(link_flags.paths.len());\n  for raw_path in &link_flags.paths {\n    let abs = resolve_link_path(&cwd, raw_path);\n    if !abs.exists() {\n      bail!(\"Cannot link '{}': directory does not exist\", raw_path);\n    }\n    if !abs.is_dir() {\n      bail!(\"Cannot link '{}': not a directory\", raw_path);\n    }\n    let has_config =\n      abs.join(\"deno.json\").exists() || abs.join(\"deno.jsonc\").exists();","sourceCodeStart":1455,"sourceCodeEnd":1491,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/pm/mod.rs#L1455-L1491","documentation":"`deno link` resolves link targets relative to the directory containing deno.json. Here Path::parent() returned None, meaning the config path has no parent — i.e. deno.json sits at the filesystem root ('/'). Deno cannot compute a base directory for relative link paths in that case.","triggerScenarios":"A deno.json literally at / (or a drive root on Windows); almost always an accident of a container or CI setup that placed the project at the filesystem root.","commonSituations":"Docker images copying deno.json to /; misconfigured CI checkouts into the root directory; chroot environments.","solutions":["Move the project into a subdirectory (e.g. /app) with deno.json beside the sources","Fix the Dockerfile/CI checkout destination so the repo lands in a normal directory"],"exampleFix":"# Dockerfile before\nCOPY deno.json /\n# after\nWORKDIR /app\nCOPY deno.json .","handlingStrategy":"validation","validationCode":"# refuse to operate from the filesystem root\n[ \"$(pwd -P)\" != \"/\" ] || { echo \"project at filesystem root — move it into a subdirectory\" >&2; exit 2; }\ndeno link \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never check out or COPY a project into / — always use a workdir like /app","Validate CI/Docker layouts once in a lint step for the repo layout"],"tags":["pm","link","path","filesystem-root"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}