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 := ""