jdx/mise · error
Cannot use :task syntax outside of monorepo root directory
Error message
Cannot use :task syntax outside of monorepo root directory
What it means
Inside a monorepo, ':task' references are resolved relative to the current package scope, which requires knowing the current working directory's position under the monorepo root. When the CWD cannot be mapped to a package scope inside the monorepo (e.g. running from the root itself or outside any package), colon-prefixed references are rejected; bare names are passed through for global matching.
Solutions
- cd into the specific package directory before using ':task' syntax
- Use the full '//package:task' path form to name the package explicitly
- Use the bare task name for global matching across the monorepo
- Add a mise.toml/package definition for the directory if it should be a valid scope
Example fix
// before (at repo root) mise run :build // after mise run //packages/api:build # or cd packages/api && mise run :build
Defensive patterns
Strategy: fallback
Validate before calling
[ "$(pwd)" != "$(git rev-parse --show-toplevel 2>/dev/null)" ] || echo 'at repo root: use //pkg:task form'
Try / catch
cd "$(git rev-parse --show-toplevel)/packages/api" && mise run :build || mise run //packages/api:build
Prevention
- cd into a package directory before using ':task'
- Prefer explicit '//pkg:task' references in CI
- Map monorepo layout before writing task refs
- Don't run scoped tasks from repo root or non-package dirs
When it happens
Trigger: Running `mise run :task` while inside the monorepo but in a directory that has no associated task scope — typically the monorepo root directory or a directory outside all packages.
Common situations: Running from the repository root expecting ':task' to pick a default package; running from a scratch/build directory inside the repo that is not a package; CI checking out the repo and running at top level.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- cannot encode # as JSON
- Cannot use :task syntax without a current working directory
- Cannot use :task syntax without a monorepo root
- {err}
- missing task name in monorepo path
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/abf220daf6714a9c.
Report an issue: GitHub.
Appendix: source
Thrown at src/task/task_load_context.rs:247
.collect();
cwd.ancestors()
.find(|a| *a == monorepo_root || roots.iter().any(|r| r == a))
.unwrap_or(cwd)
} else {
cwd
};
if let Some(scope) = monorepo_scope(&monorepo_root, scope_dir) {
// For bare task names, only expand if we're actually in the monorepo
// For colon patterns, always expand (and error if outside monorepo)
if is_colon_pattern {
Ok(format!("{scope}{task}"))
} else {
Ok(format!("{scope}:{task}"))
}
} else {
if is_colon_pattern {
bail!("Cannot use :task syntax outside of monorepo root directory");
}
// Bare name outside monorepo - return as-is for global matching
Ok(task.to_string())
}
} else {
if is_colon_pattern {
bail!("Cannot use :task syntax without a current working directory");
}
Ok(task.to_string())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_monorepo_scope() {View on GitHub (pinned to 533346cc37)