Skip to content

Commit e87ff18

Browse files
committed
[lib/prep.sh] Limit calls to cargo install --list for plugins.
When checking for an installing plugins, there isn't a need to call cargo for each plugin to check. While this is just-as-good as previous behavior, it also limits any issues when calling a Cargo subcommand that might fail. Presently, there are times where a race exists and either `STDOUT` or `STDERR` might disppear when Rustup (or potentially Cargo) is used in a shell pipeline, leading to a program panic with `failed printing to stdout: Broken pipe (os error 32)`. This change tries to minimize the probability that this occurs until a more robust upstream fix has landed. References: rust-lang/rustup#1730 References: rust-lang/rustup#1765 Signed-off-by: Fletcher Nichol <fnichol@nichol.ca>
1 parent b312a46 commit e87ff18

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/prep.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ install_rust() {
457457
local rustc="$HOME/.cargo/bin/rustc"
458458
local cargo="$HOME/.cargo/bin/cargo"
459459
local rustup="$HOME/.cargo/bin/rustup"
460+
local installed_plugins
460461

461462
header "Setting up Rust"
462463

@@ -482,8 +483,9 @@ install_rust() {
482483
"$rustup" component add rust-src | indent
483484
"$rustup" component add rustfmt | indent
484485

486+
installed_plugins="$("$cargo" install --list | grep ':$' | cut -d ' ' -f 1)"
485487
for plugin in cargo-watch cargo-edit cargo-outdated; do
486-
if ! "$cargo" install --list | grep -q "$plugin"; then
488+
if ! echo "$installed_plugins" | grep -q "^$plugin\$"; then
487489
info "Installing $plugin"
488490
"$cargo" install "$plugin" 2>&1 | indent
489491
fi

0 commit comments

Comments
 (0)