From 5a0cfe92e15abe3ccac935f9e8c6da3ffe6d8816 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 1 Aug 2026 16:34:48 +0000 Subject: [PATCH] fix: flush log file, show last lines in error output --- internal/native/native.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/native/native.go b/internal/native/native.go index 4cd6d2a..565b239 100644 --- a/internal/native/native.go +++ b/internal/native/native.go @@ -146,11 +146,23 @@ http { if err == nil { setupCmd.Stdout = logFile setupCmd.Stderr = logFile - defer logFile.Close() } - - if err := setupCmd.Run(); err != nil { - return fmt.Errorf("installation failed — check %s/install.log: %w", workDir, err) + runErr := setupCmd.Run() + if logFile != nil { + logFile.Close() + } + if runErr != nil { + // Read the log for the error message + if data, err := os.ReadFile(filepath.Join(workDir, "install.log")); err == nil && len(data) > 0 { + lines := strings.Split(string(data), "\n") + // Print last few lines as the error + start := len(lines) - 5 + if start < 0 { + start = 0 + } + return fmt.Errorf("%s", strings.Join(lines[start:], "\n")) + } + return fmt.Errorf("installation failed (exit %v) — check %s/install.log", runErr, workDir) } // 6. Enable and start systemd service