{"record":{"id":"5b74dddf4eb3ab73","repo":"jdx/mise","slug":"cycle-detected-in-tool-overrides","errorCode":null,"errorMessage":"Cycle detected in tool overrides","messagePattern":"Cycle detected in tool overrides","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/toolset/mod.rs","lineNumber":681,"sourceCode":"\n        let mut sorted_ids: Vec<&str> = Vec::with_capacity(graph.node_count());\n        while let Some(Reverse((_, _, id))) = pq.pop() {\n            sorted_ids.push(id);\n\n            for neighbor in graph.neighbors(id) {\n                if let Some(deg) = in_degree.get_mut(neighbor) {\n                    *deg -= 1;\n                    if *deg == 0 {\n                        let p = priorities[neighbor];\n                        let idx = original_index[neighbor];\n                        pq.push(Reverse((p, idx, neighbor)));\n                    }\n                }\n            }\n        }\n\n        if sorted_ids.len() != graph.node_count() {\n            bail!(\"Cycle detected in tool overrides\");\n        }\n\n        let order: HashMap<&str, usize> = sorted_ids\n            .iter()\n            .enumerate()\n            .map(|(i, &id)| (id, i))\n            .collect();\n        installed.sort_by_cached_key(|(b, _)| order.get(b.id()).copied().unwrap_or(usize::MAX));\n\n        Ok(())\n    }\n\n    pub(crate) async fn which(\n        &self,\n        config: &Arc<Config>,\n        bin_name: &str,\n    ) -> Option<(Arc<dyn Backend>, ToolVersion)> {\n        let mut installed = self.list_current_installed_versions(config);","sourceCodeStart":663,"sourceCodeEnd":699,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/toolset/mod.rs#L663-L699","documentation":"`sort_by_overrides` builds a dependency graph among tool override requests and topologically sorts them. If the number of sorted nodes is less than the graph's node count, a cycle exists in the tool override relationships, which makes a deterministic order impossible, so it bails.","triggerScenarios":"Calling toolset construction/sorting where override dependencies form a cycle — e.g. tool A's overrides point at tool B and B's at A (directly or transitively).","commonSituations":"Mistaken override chains in config (mise.toml `[tools]`/overrides referencing each other), or tool definitions whose dependency edges loop after a config merge.","solutions":["Inspect your tool overrides in mise.toml for mutually-referencing entries and break the cycle.","Simplify override configuration — usually only one tool needs the override.","Reduce the config to one tool at a time to find which pair cycles.","Check for override cycles introduced by a recently added config file in the hierarchy."],"exampleFix":"// before\n[tools]\nnode = { version = \"20\", overrides = { python = \"3.12\" } }\npython = { version = \"3.12\", overrides = { node = \"20\" } }\n// after\n[tools]\nnode = \"20\"\npython = \"3.12\"","handlingStrategy":"validation","validationCode":"// ensure each tool is overridden at most once\nlet mut seen = std::collections::HashSet::new();\nfor req in overrides { if !seen.insert(req.target()) { panic!(\"duplicate override target: {}\", req.target()); } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure at most one override per tool dependency.","Keep override chains one level deep where possible.","Audit added [tools]/overrides entries when this error appears — a cycle was just introduced."],"tags":["cycle","topological-sort","config"],"backgroundTag":"invalid-config-value","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"}