Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/wkg/src/wit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ pub async fn temp_wit_file(package: &PackageRef, bytes: &[u8]) -> anyhow::Result
impl FetchArgs {
pub async fn run(self) -> anyhow::Result<()> {
let cwd = std::env::current_dir()?;
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> {

{
root = None;
}

let dirs = if let Some(dir) = self.dir.clone() {
vec![dir]
Expand Down
19 changes: 19 additions & 0 deletions crates/wkg/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,25 @@ async fn fetch_workspace_packages() {
}
}

#[tokio::test]
async fn fetch_from_member_manifest_uses_member_context() {
let fixture = common::load_fixture("fetch-workspace-member").await;
let member = fixture.fixture_path.join("member/wit");
let mut command = fixture.command();
command.current_dir(&member).args(["fetch", "."]);

let status = command.status().await.expect("spawn wkg fetch");
assert!(status.success(), "member fetch should succeed");
assert!(
member.join("wkg.lock").exists(),
"member fetch should create a member lock file"
);
assert!(
!fixture.fixture_path.join("wkg.lock").exists(),
"member fetch should not create a workspace lock file"
);
}

#[tokio::test]
pub async fn check() {
// Use an explicit config that maps `wasi` to `wasi.dev`.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package test:member;

world member {}
2 changes: 2 additions & 0 deletions crates/wkg/tests/fixtures/fetch-workspace-member/wkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["member/wit"]