denoland/deno · error
Could not determine directory of '{}'
Error message
Could not determine directory of '{}' What it means
`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.
Source
Thrown at cli/tools/pm/mod.rs:1473
ConfigKind::DenoJson,
url_to_file_path(&deno_json.specifier)?,
)?,
None => bail!("No deno.json found; there are no linked packages to unlink"),
};
Ok((cli_factory, deno_config))
}
pub async fn link(
flags: Arc<Flags>,
link_flags: LinkFlags,
) -> Result<(), AnyError> {
let (cli_factory, mut deno_config) = load_deno_config_for_link(&flags, true)?;
let cwd = cli_factory.cli_options()?.initial_cwd().to_path_buf();
let config_dir = deno_config
.path
.parent()
.ok_or_else(|| {
deno_core::anyhow::anyhow!(
"Could not determine directory of '{}'",
deno_config.path.display()
)
})?
.to_path_buf();
// Validate every path and compute the relative form we'll store.
let mut resolved = Vec::with_capacity(link_flags.paths.len());
for raw_path in &link_flags.paths {
let abs = resolve_link_path(&cwd, raw_path);
if !abs.exists() {
bail!("Cannot link '{}': directory does not exist", raw_path);
}
if !abs.is_dir() {
bail!("Cannot link '{}': not a directory", raw_path);
}
let has_config =
abs.join("deno.json").exists() || abs.join("deno.jsonc").exists();View on GitHub (pinned to 89f33cbef2)
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
Example fix
# Dockerfile before COPY deno.json / # after WORKDIR /app COPY deno.json .
Defensive patterns
Strategy: validation
Validate before calling
# refuse to operate from the filesystem root
[ "$(pwd -P)" != "/" ] || { echo "project at filesystem root — move it into a subdirectory" >&2; exit 2; }
deno link "$@" Prevention
- 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
When it happens
Trigger: 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.
Common situations: Docker images copying deno.json to /; misconfigured CI checkouts into the root directory; chroot environments.
Related errors
- Could not load or create deno.json
- Unexpected third argument to Deno.bench()
- A deno.json file could not be found or created
- No lockfile found. Run `deno install` first.
- Unable to construct URL from the path of cwd: {}
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/9a147b64ed8c2429.
Report an issue: GitHub.