{"record":{"id":"41e0edc8618ed706","repo":"jdx/mise","slug":"cannot-use-task-syntax-without-a-current-working","errorCode":null,"errorMessage":"Cannot use :task syntax without a current working directory","messagePattern":"Cannot use :task syntax without a current working directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/task_load_context.rs","lineNumber":254,"sourceCode":"        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() {\n        let root = Path::new(\"repo\");\n        assert_eq!(monorepo_scope(root, root), Some(\"//\".to_string()));\n        assert_eq!(\n            monorepo_scope(root, &root.join(\"apps\").join(\"api\")),\n            Some(\"//apps/api\".to_string())\n        );\n        assert_eq!(monorepo_scope(root, Path::new(\"other\")), None);","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/task/task_load_context.rs#L236-L272","documentation":"expand_colon_task_syntax needs the current working directory to compute the monorepo package scope for ':task' references. When the process has no current working directory (deleted CWD, or unavailable path), any colon-prefixed reference cannot be scoped and is rejected; bare names still resolve.","triggerScenarios":"Running `mise run :task` when std::env::current_dir() fails — typically because the shell's current directory was deleted, or in exotic sandboxes where CWD is unavailable.","commonSituations":"A terminal left in a directory removed by a build cleanup or git operation; container/CI steps that rm the working directory before invoking mise; running from a mount that was unmounted.","solutions":["cd to a valid existing directory and re-run","Restore/recreate the deleted directory your shell was in","Restart the shell to reset its CWD","Avoid ':'-prefixed task refs; use the full '//pkg:task' form or a bare task name"],"exampleFix":"// before (shell cwd deleted)\nmise run :build\n// after\ncd /path/to/repo/packages/api\nmise run :build","handlingStrategy":"validation","validationCode":"CWD=$(pwd) || { echo 'current directory unavailable'; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! CWD=$(pwd) 2>/dev/null; then echo 'cwd deleted; cd to a valid dir' >&2; exit 1; fi; mise run :task","preventionTips":["Don't delete directories your shell is cd'd into","Restart shells after build cleanups remove dirs","Check pwd works before scripted mise calls in CI","Use absolute-path task refs when CWD may be unstable"],"tags":["tasks","working-directory","filesystem"],"backgroundTag":"missing-env-var","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"}