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
Consider trying:
sudo mount -o remount exec /tmp
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.
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.
To fix this issue on my Chromebook I just remounted ~/tmp
as executable. There may be security implications in doing this, but since go run
works on other platforms I figure maybe it's not that bad (especially on a local dev machine):
sudo mount -i -o remount,exec /tmp/
I added this to my .bash_profile
script.