1

When trying to run a simple compiled (with go build -o hello) "Hello world"-ish Go program on another macOS (M1 Air 2020), I get the following error:

bash-3.2$ ./hello 
bash: ./hello: Operation not permitted

The program runs fine on my machine though.

Following is its source code:

package main

import "fmt"

func main() {
    fmt.Println("Why can't you run me?")
}

Do I need to sign the binary in some way (if so, please tell me how or provide links)? Or something else is the problem?

go env:

~/r/test 1m 51.8s ❱ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/fperson/Library/Caches/go-build"
GOENV="/Users/fperson/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/fperson/.asdf/installs/golang/1.16.4/packages/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/fperson/.asdf/installs/golang/1.16.4/packages"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/fperson/.asdf/installs/golang/1.16.4/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/fperson/.asdf/installs/golang/1.16.4/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/fperson/random/test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/mh/02gmkb756x15018g919jcg980000gn/T/go-build3982328171=/tmp/go-build -gno-record-gcc-switches -fno-common"
f-person
  • 331
  • 5
  • 16
  • 2
    'Operation not permitted' seems to indicate a permissions problem -- perhaps you did not enable execute permission when you copied the binary? Try `chmod +x hello` to enable execute permission. – Chris Dodd Dec 28 '21 at 20:40
  • I tried `chmod +x hello` on the target machine, no luck :( – f-person Dec 29 '21 at 06:08
  • After some more Googling I came across people fixing this issue by giving full disk access to the terminal emulator they use. However, I want to use a compiled Go app from a macOS `App`. Will try to give full disk access permission to the terminal emulator on the target machine – f-person Dec 29 '21 at 06:27
  • You are running a 3rd-party bash; you may need to add full access in privacy settings in order to allow the script to access external modules. – Richard Barber Dec 29 '21 at 07:53
  • What do you mean by "running 3rd-party bash"? This happens on zsh too. I tried to give the terminal emulator full disk access but it wasn't present in settings – f-person Dec 29 '21 at 09:47

0 Answers0