{"record":{"id":"c8dbb02ef2d0d6ef","repo":"jdx/mise","slug":"executor-must-be-initialized-before-running-tasks","errorCode":null,"errorMessage":"executor must be initialized before running tasks","messagePattern":"executor must be initialized before running tasks","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/run.rs","lineNumber":1351,"sourceCode":"                .executor\n                .as_ref()\n                .map(|e| e.is_interrupted())\n                .unwrap_or(false)\n    }\n\n    fn mark_interrupted(&self) {\n        if let Some(executor) = &self.executor {\n            executor.mark_interrupted();\n        }\n    }\n\n    async fn run_task_sched(\n        &self,\n        ctx: TaskRunContext<'_>,\n    ) -> Result<crate::task::task_executor::TaskRunOutcome> {\n        self.executor\n            .as_ref()\n            .expect(\"executor must be initialized before running tasks\")\n            .run_task_sched(ctx)\n            .await\n    }\n\n    fn add_failed_task(&self, task: Task, status: Option<i32>) {\n        if let Some(executor) = &self.executor {\n            executor.add_failed_task(task, status);\n        }\n    }\n\n    fn validate_task(&self, task: &Task) -> Result<()> {\n        use crate::file;\n        use crate::ui;\n        if self.task_cache.enabled() && task.cache.as_ref().is_some_and(|cache| cache.enabled) {\n            Settings::get().ensure_experimental(\"task artifact caching\")?;\n        }\n        if task.rust_cache.as_ref().is_some_and(|cache| cache.enabled) {\n            Settings::get().ensure_experimental(\"Rust action caching\")?;","sourceCodeStart":1333,"sourceCodeEnd":1369,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/cli/run.rs#L1333-L1369","documentation":"The task-scheduling entry point of `mise run` forwards to TaskExecutor: `self.executor.as_ref().expect(\"executor must be initialized before running tasks\").run_task_sched(ctx)` (src/cli/run.rs:1343-1353). The executor is created earlier via setup_executor during run setup; this expect enforces ordering — scheduling must not run before initialization succeeded. It is an API-misuse guard inside the run pipeline, not a user-configurable state.","triggerScenarios":"Code that drives the task runner (run_task_sched) without having gone through the setup steps that populate self.executor — e.g. a new subcommand or test harness wiring TaskRunContext directly, or a refactor reordering setup. Ordinary `mise run` invocations initialize the executor first or fail during setup.","commonSituations":"Contributors adding alternate entry points to task execution; embedders reusing the run pipeline in tests. Unlike mark_interrupted/add_failed_task just above (which gracefully tolerate None), run_task_sched hard-requires the executor because it cannot do anything without it.","solutions":["If hit as a user: update mise; the run flow in that build invokes scheduling before initialization","As a contributor: call setup_executor() (and fail on its Err) before any code path that can reach run_task_sched; consider returning a bail!(\"executor not initialized\") instead of expect for earlier diagnostics","In tests/harnesses, drive the public run() entry rather than run_task_sched directly","Report at https://github.com/jdx/mise/issues with backtrace"],"exampleFix":"// before: scheduling reached without setup\nlet outcome = self.run_task_sched(ctx).await; // executor None -> panic\n\n// after: initialize first, propagate setup errors\nself.setup_executor()?;\nlet outcome = self.run_task_sched(ctx).await?;","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Drive task execution through the public run() entry point, not run_task_sched internals","Contributors: guarantee setup_executor() precedes every schedulable path","Report invariant panics upstream with backtraces"],"tags":["run","task-executor","invariant","panic","internal","scheduling"],"backgroundTag":"internal-invariant-violation","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}