The glide install command returns [ERROR] $GOPATH is not set

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

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&#39;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&#39;t need sudo for glide&#39;s installation or using it as long as $GOPATH is readable, writeable and executable by you. I don&#39;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&#39;t need the `sudo` part of the command. Glide will download your dependencies on ~/go/src/github.com/btcsuite/btcd/vendor, so you don&#39;t need superuser permissions for anything. Since you&#39;re running the command as `sudo` your environment variables are not set as If you&#39;re executing your command as `yako`

</details>



huangapple
  • 本文由 发表于 2017年2月27日 06:14:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/42474874.html
匿名

发表评论

匿名网友

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

确定