"gcc": executable file not found in %PATH% when using mongo-go-driver

Viewed 4986

I want to use mongodb driver.But I get the following error:

go.mongodb.org/mongo-driver/vendor/github.com/DataDog/zstd exec: "gcc": executable file not found in %PATH%

2 Answers

The issue is that your library depends on gcc to run.

1. Linux/Containers

If you are running in a container, you can try two options:

  1. you can build your app without CGO with the following command:
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o yourBinary
  1. You can try to install gcc into your container. If it is an alpine based container, run
RUN apk update && apk add --no-cache gcc

You could also need musl-dev package, but you should try without it first.

2. Windows

Since MacOS and most Linux distros come with GCC, I guess you could be using Windows. In this case, you need to install MinGW.

I know this is old but I ran into this problem too, About Alexey answer, on windows, you should install MinGW and add the path to win environment. You should follow this. In case MinGW did not work, you can install this one which worked perfectly for me on windows.

Related