Go fork/exec permission denied error

后端 未结 5 1834
终归单人心
终归单人心 2021-01-04 10:09

I recently installed Go onto our server with CentOS 6.3. The install appears to have gone fine. However I made a test \"hello world\" script, and when I run I get the foll

5条回答
  •  遥遥无期
    2021-01-04 10:55

    Just guessing: Your nix perhaps disables for security reasons executing programs in /tmp. It might be configurable in CentOS, but I don't know that.

    The alternative solution: It seems you're trying go run to execute a Go program (which is as script as C is a script). Try (assuming $GOPATH=~, the easy possibility) instead a normal build, i.e. instead of

    me:~/src/foo$ go run main.go
    

    try

    me:~/src/foo$ go build # main.go should not be necessary here
    me:~/src/foo$ ./foo
    

    This approach will still use /tmp-whatever to create the binary, IIRC, but it will not attempt to execute it from there.

    PS: Do not run these command as root. No need for that with correct setup.

提交回复
热议问题