jdx/mise · error
workspace project cannot both add and remove dependency
Error message
workspace project {id:?} cannot both add and remove dependency {dependency:?} What it means
A workspace project's depends_add and depends_remove override sets must be disjoint. If the same dependency id appears in both, mise cannot determine the final dependency set and throws this error naming the project and the conflicting dependency.
Solutions
- Remove the dependency from depends_remove if the intent is to add it
- Remove the dependency from depends_add if the intent is to drop it
- If base config declares it and you want it removed, delete the matching depends_add entry
Example fix
# before [workspace.project.app] depends_add = ["util"] depends_remove = ["util"] # after [workspace.project.app] depends_add = ["util"]
Defensive patterns
Strategy: validation
Validate before calling
fn disjoint_depends(cfg: &ProjectConfig) -> Result<(), String> {
let clash: Vec<_> = cfg.depends_add.intersection(&cfg.depends_remove).collect();
if !clash.is_empty() {
return Err(format!("depends_add and depends_remove overlap: {clash:?}"));
}
Ok(())
} Try / catch
if let Err(e) = validate_project_config(&cfg) {
if e.to_string().contains("cannot both add and remove") {
eprintln!("resolve add/remove conflict, then re-validate");
}
} Prevention
- Decide per dependency whether the override adds or removes it; never write it in both sets
- When layering configs, merge depends_add/depends_remove and check intersection before saving
- Avoid copy-pasting entries between the two lists
When it happens
Trigger: Config for project {id} lists dependency {dependency} under both depends_add and depends_remove; caught during project config validation.
Common situations: Layered config files (global + local) each adding and removing the same dependency; copy-paste edits appending to both lists.
Related errors
- workspace project depends on unknown project
- bootstrap resource ' ' depends on missing resource
- Cargo workspace member pattern
- failed to discover workspace providers
- removed workspace project
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/3992c1960c9cf898.
Report an issue: GitHub.
Appendix: source
Thrown at src/task/workspace.rs:1166
}
}
fn validate_override(id: &ProjectId, config: &WorkspaceProjectOverride) -> Result<()> {
if config.remove
&& (config.root.is_some()
|| config.metadata.is_some()
|| config.depends.is_some()
|| !config.depends_add.is_empty()
|| !config.depends_remove.is_empty())
{
bail!("removed workspace project {id:?} cannot define other overrides");
}
if let Some(dependency) = config
.depends_add
.intersection(&config.depends_remove)
.next()
{
bail!("workspace project {id:?} cannot both add and remove dependency {dependency:?}");
}
Ok(())
}
fn parse_dependency_ids(
project_id: &ProjectId,
field: &str,
dependencies: &BTreeSet<String>,
) -> Result<BTreeSet<ProjectId>> {
dependencies
.iter()
.map(|dependency| {
dependency.parse::<ProjectId>().map_err(|err| {
eyre::eyre!(
"workspace project {project_id:?} has invalid {field} entry {dependency:?}: {err}"
)
})
})View on GitHub (pinned to 533346cc37)