i have this issue when building go app which requires cgo

arahulc91TRIAL

8 months ago

15 [stage-0 8/8] RUN --mount=type=cache,id=s/fedf8f7d-5a74-4677-818a-95e12d633617-/root/cache/go-build,target=/root/.cache/go-build CGO_ENABLED=1 go build .

15 0.602 # runtime/cgo

15 0.602 cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH

15 ERROR: process "/bin/bash -ol pipefail -c CGO_ENABLED=1 go build ." did not complete successfully: exit code: 1

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

2 Replies

arahulc91TRIAL

8 months ago

i managed to fix the issue by using the custom build command:
apt-get update && apt-get install -y gcc && CGO_ENABLED=1 go build -o out .

If there is a better way then do let me know. please


8 months ago

Try simply setting the service variable - https://nixpacks.com/docs/providers/go#environment-variables