Skip to content

fix(resolver,config): remove references to root package in override dependencies#202

Open
mkatychev wants to merge 1 commit intobytecodealliance:mainfrom
mkatychev:fix/overrides-self
Open

fix(resolver,config): remove references to root package in override dependencies#202
mkatychev wants to merge 1 commit intobytecodealliance:mainfrom
mkatychev:fix/overrides-self

Conversation

@mkatychev
Copy link
Copy Markdown
Member

@mkatychev mkatychev commented Apr 24, 2026

Currently having a "workspace" level wkg.toml is not possible since for any package being built, they will also show up as a dependency in the config:

# wkg.toml
[overrides]
"namespace:foo" = { path = "./foo" }
"namespace:bar" = { path = "./bar" }
$ wkg wit build --wit-dir ./foo/

Error: failed to merge package from directory `.`

Caused by:
    attempting to re-add package `namespace:foo@7.2.0` when it's already present in this `Resolve`

Comment on lines +733 to +737
// handle cases for a workspace level `wkg.toml` where overrides may reference
// the package being built
if package.main.name == root.main.name {
continue;
}
Copy link
Copy Markdown
Member Author

@mkatychev mkatychev Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this or perhaps resolve_dependencies is the best place to handle this case but this should apply to local or registry packages regardless if the dependency name+namespace+version match that of the root:

// add deps from config first in case they're local deps and then add deps from the directory
if let Some(overrides) = config.overrides.as_ref() {
for (pkg, ovr) in overrides.iter() {
let pkg: PackageRef = pkg.parse().context("Unable to parse as a package ref")?;
let dep = match (ovr.path.as_ref(), ovr.version.as_ref()) {
(Some(path), v) => {
if v.is_some() {
tracing::warn!("Ignoring version override for local package");
}
let path = tokio::fs::canonicalize(path)
.await
.with_context(|| format!("resolving local dependency {}", path.display()))?;
Dependency::Local(path)
}
(None, Some(version)) => Dependency::Package(RegistryPackage {
name: Some(pkg.clone()),
version: version.to_owned(),
registry: None,
}),
(None, None) => {
tracing::warn!("Found override without version or path, ignoring");
continue;
}
};
tracing::debug!(dependency = %dep);
resolver
.add_dependency(&pkg, &dep)
.await
.with_context(|| format!("unable to add dependency {dep}"))?;
}
}
let (_name, packages) = get_packages(path)?;

My one concern is the comment on L180 making the get_pacakges move from L212 tricky.

@mkatychev mkatychev changed the title fix(resolver,config): filter out [overrides] references to self fix(resolver,config): remove references to self in override dependencies Apr 24, 2026
@mkatychev mkatychev changed the title fix(resolver,config): remove references to self in override dependencies fix(resolver,config): remove references to root package in override dependencies Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant