无法在搭载 M1 芯片的 Macbook 上安装 Go 包。

huangapple go评论123阅读模式
英文:

Unable to install Go packages in Macbook with M1 chip

问题

当我在delve文件夹中运行命令"go install github.com/go-delve/delve/cmd/dlv"时,在我的go路径中下载go-delve后,终端显示了以下结果:"go install github.com/go-delve/delve/cmd/dlv: mkdir /Desktop: read-only file system"。

当我搜索同样的问题时,我找到了一个网站(https://www.dev2qa.com/how-to-fix-read-only-file-system-error-when-run-mkdir-command-on-macos/),它要求我在MacBook上禁用系统完整性保护,并要求我在Mac启动后立即按住Option键或Command + R键,直到我看到一个"console/terminal"模式的引导。但当我尝试这样做时,没有任何反应。

我不知道该怎么办。请指导我正确安装dlv和其他go包的方法。

英文:

When I ran the command "go install github.com/go-delve/delve/cmd/dlv" in the delve folder, after downloading go-delve in my go path, the terminal showed the following result:
"go install github.com/go-delve/delve/cmd/dlv: mkdir /Desktop: read-only file system"
Terminal result put here

When I googled the same, I came across a website(https://www.dev2qa.com/how-to-fix-read-only-file-system-error-when-run-mkdir-command-on-macos/) which requires me to disable System Integrity Protection on my MacBook and it asks me to hold the option key or command + R immediately after Mac chimes in reboot after starting the MacBook, until I see a boot in a "console/terminal" mode.. But nothing happened when I tried doing that.
I am not knowing what to do. Please guide me through the right way to install dlv and other packages of go successfully on my Macbook.

答案1

得分: 1

  1. 确保你使用正确的 Go 版本(1.16 或更高版本,arm64)
$ go version
go version go1.17.1 darwin/arm64
  1. 通过以下命令确保 env 设置正确
$ go env

检查 GOROOTGOPATHGOARCHGOBIN

  1. 尝试直接安装
$ go install github.com/go-delve/delve/cmd/dlv@latest

你遇到的错误是因为你没有 /Desktop 的权限,我确定安装 dlv 不需要这样的权限,它会安装到 ~/go/bin

英文:
  1. make sure you use the right go version (1.16 or later, arm64)
$ go version
go version go1.17.1 darwin/arm64
  1. make sure the env is right by this command
$ go env

check GOROOT GOPATH GOARCH GOBIN

  1. try to install it directly
$ go install github.com/go-delve/delve/cmd/dlv@latest

your error occurs because you have no permission of /Desktop, and i'm sure install dlv don't need something like this, it will install to ~/go/bin

huangapple
  • 本文由 发表于 2021年10月6日 06:01:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/69457721.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定