doujia5863 2014-12-14 22:47
浏览 619
已采纳

无法在Win7上干净地设置GOOS环境变量

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条回答 默认 最新

  • dounao4179 2014-12-15 20:42
    关注

    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:
    Environment Variables
    What happens with Path System Variable is too long?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!