From ef3980a320428ee12ae85372eb62b2ea950577b4 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Wed, 25 Mar 2026 14:57:25 +0100 Subject: [PATCH] Fix goose update failing on Linux with ETXTBSY (#8107) Signed-off-by: Vincenzo Palazzo Co-authored-by: Claude Opus 4.6 (1M context) --- download_cli.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/download_cli.sh b/download_cli.sh index 1cef66662a..bc9d102fa6 100755 --- a/download_cli.sh +++ b/download_cli.sh @@ -292,7 +292,21 @@ echo "Moving goose to $GOOSE_BIN_DIR/$OUT_FILE" if [ "$OS" = "windows" ]; then mv "$EXTRACT_DIR/goose.exe" "$GOOSE_BIN_DIR/$OUT_FILE" else - mv "$EXTRACT_DIR/goose" "$GOOSE_BIN_DIR/$OUT_FILE" + # On Linux, if the target binary is currently running, writing to it fails + # with ETXTBSY ("Text file busy"). Rename the old binary out of the way + # first, then move the new one in. If the move fails, restore the old binary + # so the user is never left without an executable. + if [ -f "$GOOSE_BIN_DIR/$OUT_FILE" ]; then + mv "$GOOSE_BIN_DIR/$OUT_FILE" "$GOOSE_BIN_DIR/$OUT_FILE.old" + if ! mv "$EXTRACT_DIR/goose" "$GOOSE_BIN_DIR/$OUT_FILE"; then + echo "Error: failed to install new binary, restoring previous version" + mv "$GOOSE_BIN_DIR/$OUT_FILE.old" "$GOOSE_BIN_DIR/$OUT_FILE" + exit 1 + fi + rm -f "$GOOSE_BIN_DIR/$OUT_FILE.old" + else + mv "$EXTRACT_DIR/goose" "$GOOSE_BIN_DIR/$OUT_FILE" + fi fi # Copy Windows runtime DLLs if they exist