Repository: zng-ui/zng (language: rust)

Issue:
Cargo zng res cannot locate workspace (crate without workspace)
To reproduce:
```
cargo new --bin res-test
cd res-test
cargo zng res --metadata-dump
```

Error:
```
error: cannot locate workspace, No such file or directory (os error 2)
```


Discussion / hints:
To reproduce on the zng repo:

```
cd tools/cargo-do
cargo run --manifest-path "../../crates/cargo-zng/Cargo.toml" -- zng res --metadata-dump
```
Caused by setting the "cargo locate-project" command current dir to an empty path, because we use `manifest_path.parent()`, but manifest path is just `Cargo.toml`.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 507130d5f..c64cfb8ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
 # Unpublished
 
+* Fix `cargo zng res` in non-workspace crates.
+* Fix zr-glob not printing copied paths in subdirectories.
 
 # 0.8.1
 
diff --git a/crates/cargo-zng/src/res/about.rs b/crates/cargo-zng/src/res/about.rs
index 5aea9a388..41d4e269d 100644
--- a/crates/cargo-zng/src/res/about.rs
+++ b/crates/cargo-zng/src/res/about.rs
@@ -16,13 +16,13 @@ pub fn find_about(metadata: Option<&Path>) -> zng_env::About {
         let bin = bin.unwrap_or_else(|e| fatal!("error searching metadata, {e}"));
         let manifest = bin.parent().unwrap().parent().unwrap().join("Cargo.toml");
         if manifest.exists() {
-            let output = std::process::Command::new("cargo")
-                .arg("locate-project")
-                .arg("--workspace")
-                .arg("--message-format=plain")
-                .current_dir(manifest.parent().unwrap())
-                .output()
-                .unwrap_or_else(|e| fatal!("cannot locate workspace, {e}"));
+            let mut cmd = std::process::Command::new("cargo");
+            cmd.arg("locate-project").arg("--workspace").arg("--message-format=plain");
+            let manifest_dir = manifest.parent().unwrap();
+            if !manifest_dir.as_os_str().is_empty() {
+                cmd.current_dir(manifest_dir);
+            }
+            let output = cmd.output().unwrap_or_else(|e| fatal!("cannot locate workspace, {e}"));
 
             if output.status.success() {
                 let w2 = Path::new(std::str::from_utf8(&output.stdout).unwrap().trim()).parent().unwrap();
diff --git a/crates/cargo-zng/src/res/built_in.rs b/crates/cargo-zng/src/res/built_in.rs
index 92c3671ce..58010caf3 100644
--- a/crates/cargo-zng/src/res/built_in.rs
+++ b/crates/cargo-zng/src/res/built_in.rs
@@ -226,6 +226,7 @@ fn glob() {
                     fs::copy(source, &target)
                         .unwrap_or_else(|e| fatal!("cannot copy `{}` to `{}`, {e}", source.display(), target.display()));
                 }
+                println!("{}", display_path(&target));
             }
         } else if source.is_file() {
             // filters match 'entry'


Test patch:
diff --git a/tests/cargo-zng-res-tests/glob/test.stdout b/tests/cargo-zng-res-tests/glob/test.stdout
index 9a65e28c7..253ab3161 100644
--- a/tests/cargo-zng-res-tests/glob/test.stdout
+++ b/tests/cargo-zng-res-tests/glob/test.stdout
@@ -1,4 +1,8 @@
 tests/cargo-zng-res-tests/glob/source/filter.zr-glob
+  target/tmp/tests/cargo_zng/glob/refs/aa
+  target/tmp/tests/cargo_zng/glob/refs/ac
+  target/tmp/tests/cargo_zng/glob/refs/i/aai
+  target/tmp/tests/cargo_zng/glob/refs/i/aci
 tests/cargo-zng-res-tests/glob/source/flatten
   target/tmp/tests/cargo_zng/glob/flatten
 tests/cargo-zng-res-tests/glob/source/flatten/refs-glob.zr-glob