Permission denied when using Go Install

polaris · 2015-08-20 02:22:12 · 4377 次点击    
这是一个分享于 2015-08-20 02:22:12 的资源,其中的信息可能已经有所发展或是发生改变。
go install github.com/user/hello: open /Users/MyName/projects/go/bin/hello: permission denied

That's what I get. I have the GOROOT in my bashrc file. I have the GOPATH set up right.

Everything else is working correctly when I check with the "-x" flag.

Do I just need to change some permissions? This may just be a BASH question, idk.

edit: same thing when I tried to download and run tetris

go get github.com/k0kubun/tetris ; tetris
go install github.com/k0kubun/termbox-go: mkdir /Users/Cale/projects/go/pkg/darwin_amd64: permission denied

**评论:**

FIuffyRabbit:

What is the output of

ls -l /Users/MyName/projects/go/bin
analogphototaker:

Nothing

calebdoxsey:

What does go env give you?

Two ideas:

  • Do you have a space in your username? That can sometimes cause problems.
  • Maybe the permissions really are set such that go can't create the folders. You could try: chmod -R 777 ~/projects.
analogphototaker:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/MyName/projects/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT=""
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

A space in the user on my computer? No, it's just my first name.

I got "Operation not permitted" when I tried chmod on the projects folder.

calebdoxsey:

It sounds like the permissions on your home folder are wrong. Try the same command, but this time with sudo: sudo chmod -R 777 ~/projects.

If you don't have admin access on your computer (needed for sudo) and you don't have write access to your own home directory, then I'm not sure what you can do to fix this.

Maybe you can create another folder in your home directory and try again?

cd ~
mkdir go
env GOPATH=$HOME/go get github.com/k0kubun/tetris
$HOME/go/bin/tetris

If that works just update your GOPATH in your bashrc. (I actually tend to use $HOME as my GOPATH, and then all my code is in $HOME/src, and everything gets installed to $HOME/bin, which plays nice with other things I want to put in there)


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

4377 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传