fix: go build module cache permission + README sudo

- Set GOMODCACHE + GOPATH to /opt/receiptnext/.go (writable location)
- Removes sudo from README one-liner — script self-elevates
- Build now works for users whose home directory isn't writable
This commit is contained in:
Claus Lohmar 2026-05-30 16:10:42 +00:00
parent b7fddf0069
commit 0ab9f1e1be
2 changed files with 5 additions and 1 deletions

View file

@ -9,7 +9,7 @@
## 🚀 One-Command Install ## 🚀 One-Command Install
```bash ```bash
sudo bash -c "$(curl -fsSL https://git.lohmar.co.uk/cclohmar/ReceiptNext/raw/branch/main/install.sh)" bash -c "$(curl -fsSL https://git.lohmar.co.uk/cclohmar/ReceiptNext/raw/branch/main/install.sh)"
``` ```
Or from a local clone: Or from a local clone:

View file

@ -126,6 +126,10 @@ esac
if command -v go &>/dev/null; then if command -v go &>/dev/null; then
info "Building binary from source (pure Go, no CGO)..." info "Building binary from source (pure Go, no CGO)..."
# Use a writable module cache — the user's home 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}"
CGO_ENABLED=0 go build -ldflags="-s -w" -o app . CGO_ENABLED=0 go build -ldflags="-s -w" -o app .
else else
info "Go not found — downloading pre-built binary..." info "Go not found — downloading pre-built binary..."