From 6705d20194a87c6a177de14849a7f848dba58460 Mon Sep 17 00:00:00 2001 From: Soff Chen Date: Mon, 29 Dec 2025 18:35:48 +0800 Subject: [PATCH] fix: Implement fallback log directory for file logging on read-only systems. --- internal/logging/global_logger.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/logging/global_logger.go b/internal/logging/global_logger.go index 6ea1963a..e5bd6721 100644 --- a/internal/logging/global_logger.go +++ b/internal/logging/global_logger.go @@ -95,6 +95,13 @@ func ConfigureLogOutput(loggingToFile bool, logsMaxTotalSizeMB int) error { logDir := "logs" if base := util.WritablePath(); base != "" { logDir = filepath.Join(base, "logs") + } else if loggingToFile { + // When logging to file is enabled but WRITABLE_PATH is not set, + // use a default writable location to avoid errors on read-only filesystems + // (e.g., Homebrew installations on macOS). + if home, err := os.UserHomeDir(); err == nil { + logDir = filepath.Join(home, ".cliproxyapi", "logs") + } } protectedPath := ""