From 44ff34f3789d0c4f5f61671365a701960872d0c8 Mon Sep 17 00:00:00 2001 From: verse91 Date: Mon, 27 Apr 2026 16:06:36 +0700 Subject: [PATCH] fix(init): text file busy bug on setup --- root/init.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/root/init.go b/root/init.go index 9c24429..de531f1 100644 --- a/root/init.go +++ b/root/init.go @@ -58,8 +58,18 @@ var setupCmd = &cobra.Command{ targetExe := filepath.Join(localBin, "iris") fmt.Printf("Installing iris to %s...\n", targetExe) - input, _ := os.ReadFile(exe) - _ = os.WriteFile(targetExe, input, 0755) + input, err := os.ReadFile(exe) + if err != nil { + fmt.Printf("Failed to read current executable: %v\n", err) + return + } + + _ = os.Remove(targetExe) + err = os.WriteFile(targetExe, input, 0755) + if err != nil { + fmt.Printf("Failed to write to %s: %v\n", targetExe, err) + return + } shellPath := os.Getenv("SHELL") shellName := filepath.Base(shellPath)