{"record":{"id":"abf220daf6714a9c","repo":"jdx/mise","slug":"cannot-use-task-syntax-outside-of-monorepo-root-d","errorCode":null,"errorMessage":"Cannot use :task syntax outside of monorepo root directory","messagePattern":"Cannot use :task syntax outside of monorepo root directory","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/task_load_context.rs","lineNumber":247,"sourceCode":"                .collect();\n            cwd.ancestors()\n                .find(|a| *a == monorepo_root || roots.iter().any(|r| r == a))\n                .unwrap_or(cwd)\n        } else {\n            cwd\n        };\n        if let Some(scope) = monorepo_scope(&monorepo_root, scope_dir) {\n            // For bare task names, only expand if we're actually in the monorepo\n            // For colon patterns, always expand (and error if outside monorepo)\n\n            if is_colon_pattern {\n                Ok(format!(\"{scope}{task}\"))\n            } else {\n                Ok(format!(\"{scope}:{task}\"))\n            }\n        } else {\n            if is_colon_pattern {\n                bail!(\"Cannot use :task syntax outside of monorepo root directory\");\n            }\n            // Bare name outside monorepo - return as-is for global matching\n            Ok(task.to_string())\n        }\n    } else {\n        if is_colon_pattern {\n            bail!(\"Cannot use :task syntax without a current working directory\");\n        }\n        Ok(task.to_string())\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn test_monorepo_scope() {","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/task/task_load_context.rs#L229-L265","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (at repo root)\nmise run :build\n// after\nmise run //packages/api:build\n# or cd packages/api && mise run :build","handlingStrategy":"fallback","validationCode":"[ \"$(pwd)\" != \"$(git rev-parse --show-toplevel 2>/dev/null)\" ] || echo 'at repo root: use //pkg:task form'","typeGuard":null,"tryCatchPattern":"cd \"$(git rev-parse --show-toplevel)/packages/api\" && mise run :build || mise run //packages/api:build","preventionTips":["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"],"tags":["tasks","monorepo","working-directory"],"backgroundTag":"invalid-state-transition","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}