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

  1. Remove the dependency from depends_remove if the intent is to add it
  2. Remove the dependency from depends_add if the intent is to drop it
  3. 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

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


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)