英文:
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登录,看看是否有任何差异。
另请参考:
你还可以考虑启用远程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:
-
Type "env" from your local Konsole GUI terminal. Make note of the environment variables that are particularly important to you: PATH, GOPATH, GOROOT, etc.
-
Edit your
$HOME/.profile
file (aka~/.profile
).Explicitly set those variables.
-
Try ssh again - see if there's any difference.
See also:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论