Skip to content

fix(wkg): respect member manifests during fetch - #244

Open
subotac wants to merge 1 commit into
bytecodealliance:mainfrom
subotac:fix/fetch-member-manifest
Open

fix(wkg): respect member manifests during fetch#244
subotac wants to merge 1 commit into
bytecodealliance:mainfrom
subotac:fix/fetch-member-manifest

Conversation

@subotac

@subotac subotac commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #243.

When wkg fetch ran below a workspace root, it always selected workspace mode even when the current directory had its own wkg.toml. Use the member manifest as the fetch context in that case while preserving
workspace behavior when no local manifest exists.

The regression test verifies that fetching from a member creates the member lock file rather than a workspace lock file.

Testing

  • cargo test -p wkg --test e2e fetch_from_member_manifest_uses_member_context --no-default-features
  • cargo check -p wkg --tests --no-default-features
  • cargo test -p wkg --bin wkg --no-default-features
  • cargo fmt --all -- --check

@subotac
subotac requested a review from mkatychev as a code owner July 30, 2026 17:58
Comment thread crates/wkg/src/wit.rs
let root = Manifest::load_root_workspace(&cwd).await?;
let mut root = Manifest::load_root_workspace(&cwd).await?;
if root.as_ref().is_some_and(|root| root.root_dir() != cwd)
&& tokio::fs::try_exists(cwd.join(MANIFEST_FILE_NAME)).await?

@mkatychev mkatychev Jul 31, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would this approach work if one is in a subdirectory of a member manfiest, for instance, will this work if we are in subdir?

./root
├── member
│   ├── subdir
│   │   └── file.wit
│   └── wkg.toml
└── wkg.toml

Manifest::load_root_workspace will keep walking up the path until it finds a manifest that is a workspace root.
It may be better to handle this using find_root_manifest_for_wd:

/// Find the first ancestor [`super::Manifest`] path for current working directory.
pub(crate) fn find_root_manifest_for_wd(cwd: impl AsRef<Path>) -> Option<PathBuf> {

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.

bug: wkg fetch will attempt workspace fetching even if a member manifest is present

2 participants