From 652e3de288c3d9eb2078f88cb3bd49673ae35c81 Mon Sep 17 00:00:00 2001
From: hlclarog <58982096+hlclarog@users.noreply.github.com>
Date: Tue, 29 Sep 2026 18:15:19 -0500
Subject: [PATCH] fix(cargo): skip cargo install when no crate is installed
`update_all` pipes the installed crates to `xargs -n1 cargo install`. With no
crate installed, xargs still runs `cargo install` once without arguments, so
every `dot package update_all` prints a cargo error, for example
"
is not a crate root; specify a crate to install from crates.io", and
then reports "Done".
Reading the list in a loop runs nothing for an empty list. It avoids GNU
`xargs -r`, which the BSD xargs on macOS does not reliably provide.
---
scripts/package/src/package_managers/cargo.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/scripts/package/src/package_managers/cargo.sh b/scripts/package/src/package_managers/cargo.sh
index 28903f14..f95eb5a3 100644
--- a/scripts/package/src/package_managers/cargo.sh
+++ b/scripts/package/src/package_managers/cargo.sh
@@ -1,4 +1,9 @@
cargo::update_all() {
- cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ' | xargs -n1 cargo install
+ # A plain `xargs cargo install` still runs once with no arguments when no crate is
+ # installed, and `cargo install` alone tries to install the current directory.
+ cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ' |
+ while read -r cargo_package; do
+ cargo install "$cargo_package"
+ done
output::answer "Done"
}