Permission denied when using Go Install

polaris · · 4279 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<pre><code>go install github.com/user/hello: open /Users/MyName/projects/go/bin/hello: permission denied </code></pre> <p>That&#39;s what I get. I have the GOROOT in my bashrc file. I have the GOPATH set up right. </p> <p>Everything else is working correctly when I check with the &#34;-x&#34; flag.</p> <p>Do I just need to change some permissions? This may just be a BASH question, idk.</p> <p><strong>edit</strong>: same thing when I tried to download and run tetris</p> <pre><code>go get github.com/k0kubun/tetris ; tetris go install github.com/k0kubun/termbox-go: mkdir /Users/Cale/projects/go/pkg/darwin_amd64: permission denied </code></pre> <hr/>**评论:**<br/><br/>FIuffyRabbit: <pre><p>What is the output of </p> <pre><code>ls -l /Users/MyName/projects/go/bin </code></pre></pre>analogphototaker: <pre><p>Nothing</p></pre>calebdoxsey: <pre><p>What does <code>go env</code> give you?</p> <p>Two ideas:</p> <ul> <li>Do you have a space in your username? That can sometimes cause problems.</li> <li>Maybe the permissions really are set such that go can&#39;t create the folders. You could try: <code>chmod -R 777 ~/projects</code>.</li> </ul></pre>analogphototaker: <pre><pre><code>GOARCH=&#34;amd64&#34; GOBIN=&#34;&#34; GOEXE=&#34;&#34; GOHOSTARCH=&#34;amd64&#34; GOHOSTOS=&#34;darwin&#34; GOOS=&#34;darwin&#34; GOPATH=&#34;/Users/MyName/projects/go&#34; GORACE=&#34;&#34; GOROOT=&#34;/usr/local/go&#34; GOTOOLDIR=&#34;/usr/local/go/pkg/tool/darwin_amd64&#34; GO15VENDOREXPERIMENT=&#34;&#34; CC=&#34;clang&#34; GOGCCFLAGS=&#34;-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common&#34; CXX=&#34;clang++&#34; CGO_ENABLED=&#34;1&#34; </code></pre> <p>A space in the user on my computer? No, it&#39;s just my first name. </p> <p>I got &#34;Operation not permitted&#34; when I tried chmod on the projects folder.</p></pre>calebdoxsey: <pre><p>It sounds like the permissions on your home folder are wrong. Try the same command, but this time with sudo: <code>sudo chmod -R 777 ~/projects</code>.</p> <p>If you don&#39;t have admin access on your computer (needed for <code>sudo</code>) and you don&#39;t have write access to your own home directory, then I&#39;m not sure what you can do to fix this. </p> <p>Maybe you can create another folder in your home directory and try again?</p> <pre><code>cd ~ mkdir go env GOPATH=$HOME/go get github.com/k0kubun/tetris $HOME/go/bin/tetris </code></pre> <p>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)</p></pre>

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

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