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