英文:
The glide install command returns [ERROR] $GOPATH is not set
问题
我正在尝试安装https://github.com/btcsuite/btcd。
我按照说明进行操作(除了添加sudo之外),首先安装glide,命令如下:
sudo go get -u github.com/Masterminds/glide
然后我将存储库克隆到适当的文件夹,命令如下:
git clone https://github.com/btcsuite/btcd $GOPATH/src/github.com/btcsuite/btcd
现在该存储库位于此文件夹:/Users/yako/go/src/github.com/btcsuite/btcd
问题出现在我在该文件夹中运行sudo glide install
时。我得到的错误是[ERROR] $GOPATH is not set.
我相当确定我已经正确设置了这些,因为go env GOROOT GOPATH
命令返回:
/Users/yako/go```
而`echo $GOROOT`返回`/usr/local/go`,`echo $GOPATH`返回`/Users/yako/go`。
<details>
<summary>英文:</summary>
Im trying to install https://github.com/btcsuite/btcd
I followed the instructions (with the exception of adding sudo) by first installing glide like so
`sudo go get -u github.com/Masterminds/glide`
Then I cloned the repo to the appropriate folder like so
`git clone https://github.com/btcsuite/btcd $GOPATH/src/github.com/btcsuite/btcd`
Now the repo is located at this folder: `/Users/yako/go/src/github.com/btcsuite/btcd`
The problem occurs when I run `sudo glide install` in the folder. I get `[ERROR] $GOPATH is not set.`
Im pretty sure I did set these correctly thought as the `go env GOROOT GOPATH` command returns
```/usr/local/go
/Users/yako/go```
and `echo $GOROOT` returns `/usr/local/go` and `echo $GOPATH` returns `/Users/yako/go`
</details>
# 答案1
**得分**: 3
当您以sudo身份运行时,它可能会失败,因为sudo具有与您的用户不同的环境。所以,a) 您需要为该命令设置GOPATH,b) 只要$GOPATH对您可读、可写和可执行,您就不需要sudo来安装或使用glide。我不知道为什么btcd说要使用它。
<details>
<summary>英文:</summary>
It's probably failing when you run it as sudo, because sudo has a different environment than your user. So a) you need to set GOPATH for that command, and b) you shouldn't need sudo for glide's installation or using it as long as $GOPATH is readable, writeable and executable by you. I don't know why btcd says to use it
</details>
# 答案2
**得分**: 0
你不需要命令中的 `sudo` 部分。Glide 将会在 ~/go/src/github.com/btcsuite/btcd/vendor 目录下下载你的依赖,所以你不需要超级用户权限。由于你以 `sudo` 运行该命令,你的环境变量没有被设置,就好像你是以 `yako` 执行命令一样。
<details>
<summary>英文:</summary>
You don't need the `sudo` part of the command. Glide will download your dependencies on ~/go/src/github.com/btcsuite/btcd/vendor, so you don't need superuser permissions for anything. Since you're running the command as `sudo` your environment variables are not set as If you're executing your command as `yako`
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论