denoland/deno · error
Cannot use --set-version when publishing a workspace. Change
Error message
Cannot use --set-version when publishing a workspace. Change your cwd to an individual package instead.
What it means
`--set-version` rewrites the `version` field of exactly one package config right before publishing. When publish resolves more than one config (a workspace), Deno cannot decide which member's version to change, so it refuses rather than guessing. The suggested remedy is part of the message: target an individual package.
Source
Thrown at cli/tools/publish/mod.rs:113
bail!(
"Package 'publish' field is false in '{}'.",
deno_json.specifier
);
}
error_missing_exports_field(deno_json)?;
}
None => {
bail!(
"Couldn't find a deno.json, deno.jsonc, jsr.json or jsr.jsonc configuration file in {}.",
directory_path.display()
);
}
}
}
if let Some(version) = &publish_flags.set_version {
if publish_configs.len() > 1 {
bail!(
"Cannot use --set-version when publishing a workspace. Change your cwd to an individual package instead."
);
}
if let Some(publish_config) = publish_configs.get_mut(0) {
let mut config_file = publish_config.config_file.as_ref().clone();
config_file.json.version = Some(version.clone());
publish_config.config_file = Arc::new(config_file);
}
}
validate_publish_configs(&publish_configs)?;
let auth_method =
get_auth_method(publish_flags.token, publish_flags.dry_run)?;
// Bail out early if the version is already published, before doing the
// expensive type checking and tarball preparation. Already-published
// versions are skipped with a warning (rather than erroring) so thatView on GitHub (pinned to f7822238ca)
Solutions
- cd into the individual member directory and re-run `deno publish --set-version <version>`.
- Or drop `--set-version` and bump `version` in each member's deno.json yourself, then publish from the root.
Example fix
# before (workspace root) deno publish --set-version 1.2.3 # error # after # (in workspace root) cd packages/foo && deno publish --set-version 1.2.3
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash # refuse --set-version when the cwd resolves a workspace if grep -q '"workspace"' deno.json 2>/dev/null; then echo "refusing --set-version at workspace root — cd into a member first" >&2 exit 1 fi
Prevention
- Run `--set-version` only from a member directory that has its own deno.json.
- In release scripts, assert `[ -f deno.json ] && ! grep -q '"workspace"' deno.json` before passing --set-version.
- Prefer bumping versions in config files via a script, then publish from wherever you like.
When it happens
Trigger: Running `deno publish --set-version 1.2.3` from a workspace root (or any directory where `publish_configs.len() > 1` after member discovery).
Common situations: Release scripts at the monorepo root passing `--set-version` for convenience; adding the flag while expecting all members to bump; automating releases without cd-ing into the member.
Related errors
- unable to find npm package in workspace
- No packages to publish
- Failed to publish {} packages:
- No means to authenticate. Pass a token to `--token`, or enab
- Found {} problem{}
AI-assisted analysis of denoland/deno@f7822238ca (2026-08-20).
Data as JSON: /api/errors/769e1a16b4c01be4.
Report an issue: GitHub.