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 following output.
fork/exec /tmp/go-build967564990/command-line-arguments/_obj/a.out: permission denied
Now running go env or other go commands seem to work. At first I figured it was a permission issue, however running as root user I get the same thing. An
I encountered this issue today but the solutions above did not work. Mine was fixed by simply running:
$ export TMPDIR=~/tmp/
then I was able to get the script to run with:
$ go run hello.go
hello, world
The only downside is you have to run export TMPDIR
every time you want to run an application.
Kudos to Adam Goforth
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.
I am using Fedora 31 and got a similar error which brought me here. I could not run the Go debugger used by Jetbrains IntelliJ Ultimate/GoLand without fork/exec
& permission denied
error. The solution was this:
setsebool deny_ptrace 0
See https://fedoraproject.org/wiki/Features/SELinuxDenyPtrace for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With