From 51c5d9a23ed68a0e2bb808e49f022905f48d5da3 Mon Sep 17 00:00:00 2001 From: cclohmar Date: Sat, 30 May 2026 16:13:26 +0000 Subject: [PATCH] fix: set GOCACHE alongside GOMODCACHE for users without home write access - Go build cache was trying to write to /app/.cache/go-build (unwritable) - Now uses /opt/receiptnext/.go/build instead --- install.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index d963e43..1f3823f 100755 --- a/install.sh +++ b/install.sh @@ -70,6 +70,10 @@ if [ "${1:-}" = "-update" ]; then info "Rebuilding binary..." if command -v go &>/dev/null; then + export GOMODCACHE="${INSTALL_DIR}/.go/mod" + export GOPATH="${INSTALL_DIR}/.go" + export GOCACHE="${INSTALL_DIR}/.go/build" + mkdir -p "${GOMODCACHE}" "${GOCACHE}" 2>/dev/null || sudo_if mkdir -p "${GOMODCACHE}" "${GOCACHE}" CGO_ENABLED=0 go build -ldflags="-s -w" -o app . else warn "Go not found — downloading pre-built binary..." @@ -126,10 +130,11 @@ esac if command -v go &>/dev/null; then info "Building binary from source (pure Go, no CGO)..." - # Use a writable module cache — the user's home may not be writable + # Use a writable cache — the user's home (/app/) may not be writable export GOMODCACHE="${INSTALL_DIR}/.go/mod" export GOPATH="${INSTALL_DIR}/.go" - mkdir -p "${GOMODCACHE}" 2>/dev/null || sudo_if mkdir -p "${GOMODCACHE}" + export GOCACHE="${INSTALL_DIR}/.go/build" + mkdir -p "${GOMODCACHE}" "${GOCACHE}" 2>/dev/null || sudo_if mkdir -p "${GOMODCACHE}" "${GOCACHE}" CGO_ENABLED=0 go build -ldflags="-s -w" -o app . else info "Go not found — downloading pre-built binary..."