`exec: "gcc": executable file not found in $PATH` when compiling as a module

3,838 views
Skip to first unread message

kjbo...@gmail.com

unread,
Aug 27, 2018, 5:14:18 PM8/27/18
to golang-nuts
https://gist.github.com/kevinbowrin/5f93152fdac23529e06a3a38cde88ce8


Compiling this little program:

package main


import (
       
"fmt"
       
"net/http"
)


func main
() {
        x
, _ := http.NewRequest("GET", "https://google.com", nil)
        fmt
.Println(x)
}

in the GOPATH works fine.

But if it is compiled as a Go 1.11 module outside the GOPATH, the error:

exec: "gcc": executable file not found in $PATH

is returned. 

I know I can `CGO_ENABLED=0 go build`. I'm more curious why 'mod-ing' this package causes the change in behavior.  

Thanks all.

thepud...@gmail.com

unread,
Aug 27, 2018, 6:02:16 PM8/27/18
to golang-nuts
Hi all,

In a separate (short) forum, Russ wrote:

   "Because the pre-built packages are non-module builds and can’t be reused. Sorry. Disable cgo for now or install gcc."

I suspect these are related as well:

   #26993 -- "cmd/go: prebuilt net/http not used"


   #26988 -- cmd/go: GO111MODULE=on go build requires gcc 

But I would be curious to hear any additional commentary...

--thepudds
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages