无法在Windows 7上清晰地设置GOOS环境变量。

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

Unable to cleanly set GOOS environment variable on win7

问题

我正在尝试使用golang的交叉编译功能在我的机器上(Windows 7)进行编译,以在Linux和amd64之间切换编译。

我正确设置了所有环境变量:

GOARCH = amd64
GOOS = linux

我的问题出现在我尝试通过将GOOS更改为linux或amd64来切换平台时。我使用Console 2来管理我的标准cmd、cygwin控制台和git控制台。
在使用以下命令更改GOOS后:

xset GOOS=amd64

不同的控制台显示变量的不同值,例如:

//git bash
echo $GOOS
linux
//cmd
echo %GOOS%
amd64

即使在重新启动所有控制台后仍然会出现这种情况。
此外,我突然无法访问我的系统的某些部分!尝试访问我的系统属性中的“高级系统设置”现在返回一个警告:

“%windir%\system32\systempropertiesadvanced.exe”找不到。

这让我觉得Win7突然无法处理自己的环境变量了。

这也意味着我不能再通过Windows GUI更改变量了。

最重要的是,“go”命令不再可用,我无法使用go构建任何东西。

到目前为止,我唯一的解决办法是每次更改变量时重新启动整个系统。
重新启动后,变量会更改,一切正常,直到我想再次更改GOOS。

我会非常感谢任何形式的帮助,我刚开始使用go,并且认为我可能遗漏了一些明显的东西。

提前感谢您的帮助。

英文:

I am trying to use golangs cross compilation feature to compile on my machine (windows 7) to switch between compiling for linux and amd64.

I set up everything properly and created the enviroment variables

GOARCH = amd64
GOOS = linux

My problem occurs whenever I try to switch between platforms by changing GOOS to either linux or amd64. I use Console 2 to manage my standart cmd, cygwin console and git console.
After changing GOOS with:

xset GOOS=amd64

different consoles show different values for the variable e.g:

//git bash
echo $GOOS
linux
//cmd
echo %GOOS%
amd64

This happens even after restarting all consoles.
Additionally I am suddenly unable to access parts of my system!
Trying to access my "Advanced System settings" in my System properties returns now a warning:

"%windir%\system32\systempropertiesadvanced.exe" could not be found.

which sounds to my like win7 suddenly can't handle its own environment variables anymore.

This also means that I can't change the variables through the windows GUI anymore.

On top of all that the "go" command is no longer bound and I am unable to build anything with go.

My only solution this far is to restart my entire system every time I change a variable.
After a restart the variable is changed an everything works fine until I want to change GOOS again.

I would be very happy about any kind of input, I am new to go and assume that I am missing something obvious.

Thanks in advance

答案1

得分: 1

也许你应该检查一下你的环境变量,特别是它的长度。

如果你的环境变量达到了最大大小,Windows 就无法正确访问环境变量,从而导致错误消息。

更多信息:
环境变量
当路径系统变量过长时会发生什么?

英文:

Perhaps you should check your environment variables, especially it's length.

If your environment variables hit the maximum size, windows can't access the env variables properly so it leads to your error message.

Further information:<br>
Environment Variables<br>
What happens with Path System Variable is too long?

huangapple
  • 本文由 发表于 2014年12月15日 06:47:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/27475038.html
匿名

发表评论

匿名网友

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

确定