Why would 'go build file.go' work fine at my local terminal, but give me an error over SSH?

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

Why would 'go build file.go' work fine at my local terminal, but give me an error over SSH?

问题

当我在本地终端(Ubuntu上的Konsole)运行'go build file.go'(或'go install')时,我的代码可以正确构建,没有任何警告。然而,当我通过SSH(从另一台Linux机器或使用Windows上的PuTTY)登录到同一台机器时,我会收到警告信息:

警告:设置为GOROOT(/home/[username]/go)的GOPATH无效
构建运行时:必须使用make.bash引导linux/amd64

在终端中:
'go version'报告go1.3.3 linux/amd64
'which go'报告/usr/local/go/bin/go
通过SSH:
'go version'报告go1.2.1 linux/amd64
'which go'报告/home/[username]/go/bin/go

英文:

When I run 'go build file.go' (or 'go install') at my local terminal (Konsole on ubuntu), my code builds correctly without any warnings. However, when I SSH (from another linux box or using PuTTY from Windows) into the exact same machine, I get the warning messages:
> warning: GOPATH set to GOROOT (/home/[username]/go) has no effect go
> build runtime: linux/amd64 must be bootstrapped using make.bash

In terminal:<br>
'go version' reports go1.3.3 linux/amd64<br>
'which go' reports /usr/local/go/bin/go<br>
Over SSH:<br>
'go version' reports go1.2.1 linux/amd64<br>
'which go' reports /home/[username]/go/bin/go

答案1

得分: 2

显然,你在本地(可能是GUI桌面)Ubuntu登录和ssh登录之间的环境是不同的。

这并不出乎意料。

建议:

1)从本地Konsole GUI终端中输入“env”。记下对你特别重要的环境变量:PATH、GOPATH、GOROOT等。

2)编辑你的$HOME/.profile文件(也称为~/.profile)。

显式设置这些变量。

3)再次尝试ssh登录,看看是否有任何差异。

另请参考:

https://unix.stackexchange.com/questions/101168/set-environment-variable-automatically-upon-ssh-login-no-root-access

你还可以考虑启用远程VNC:

https://www.digitalocean.com/community/tutorials/how-to-setup-vnc-for-ubuntu-12

https://askubuntu.com/questions/304017/how-to-set-up-remote-desktop-sharing-through-ssh

英文:

Clearly your environment is different between your local (presumably GUI desktop) Ubuntu logon and your ssh logon.

This isn't unexpected.

SUGGESTION:

  1. Type "env" from your local Konsole GUI terminal. Make note of the environment variables that are particularly important to you: PATH, GOPATH, GOROOT, etc.

  2. Edit your $HOME/.profile file (aka ~/.profile).

    Explicitly set those variables.

  3. Try ssh again - see if there's any difference.

See also:

https://unix.stackexchange.com/questions/101168/set-environment-variable-automatically-upon-ssh-login-no-root-access

You might also consider enabling remote VNC:

https://www.digitalocean.com/community/tutorials/how-to-setup-vnc-for-ubuntu-12

https://askubuntu.com/questions/304017/how-to-set-up-remote-desktop-sharing-through-ssh

huangapple
  • 本文由 发表于 2015年2月19日 06:08:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/28594880.html
匿名

发表评论

匿名网友

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

确定