bug(global): `Exposed name already exists` when using a custom exposed name
Checks
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pixi, using
pixi --version.
pixi 0.81.0 (also reproduces with a build of the current main branch)
Reproducible example
Commands I ran and their output:
pixi global install --channel <channel> jupyter
pixi global install --channel <channel> --environment custom --expose jupyter-custom=jupyter jupyter
pixi global update customError: × couldn't update 1 environment
╠─▶ Exposed name jupyter already existsThe global manifest ($PIXI_HOME/manifests/pixi-global.toml) that reproduces it:
[envs.jupyter]
channels = ["<channel>"]
dependencies = { jupyter = "*" }
[envs.custom]
channels = ["<channel>"]
dependencies = { jupyter = "*" }
exposed = { jupyter-custom = "jupyter" }Other files: the repository's existing test fixture tests/data/channels/channels/non_self_expose_channel_1 provides a channel that reproduces this (jupyter-core exposes jupyter, jupyter depends on it).
Issue description
Project::sync_exposed_names with ExposedType::All (which is also used for Ignore) adds an exposed mapping for every executable of the environment's direct dependencies, using the executable name as the exposed name, and does not skip executables that the environment already exposes - possibly under a custom exposed name. The extra mapping then collides with the identically named expose of the other environment, because Manifest::add_exposed_mapping only ignores the environment the mapping is added to.
Related: #2868, #7041
Expected behavior
pixi global update custom succeeds, as the environment already exposes the executable; no extra mapping should be added on update.
Source: prefix-dev/pixi