在Windows上安装时出现“拒绝访问”的错误。

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

go install on windows: "Access is Denied"

问题

我是Go编程的新手。我希望能得到你在我的一个问题上的帮助。

我需要在一个文件上执行go install命令,该文件在Windows上生成的可执行文件位于一个名为GOPATH\bin的文件夹中。

到目前为止,我通常按照以下步骤进行操作:go install <file>.go ---> <file>.exe
然而,这一次在执行<file>.exe之后,exe文件似乎不会立即完成执行,当我再次执行go install时,我会收到以下错误信息。

> C:\Users\Rahul\Desktop\Compilers\src\cs553s2013\mylexer>go install
> is_digit.go go install command-line-arguments: open
> C:\Users\Rahul\Desktop\Compilers\bin\is_ digit.exe: Access is denied.

英文:

I am new to programming in Go. I would really like your help regarding one of my problems.

I am required to do go install on a file, the executable of which (in Windows) is created in a folder called GOPATH\bin.

Until now, I typically followed the routine: go install &lt;file&gt;.go ---> &lt;file&gt;.exe.
However, this time it appears that after the execution of &lt;file&gt;.exe, the exe doesn't finish complete executing for a while and I get the following error when I go install again.

> C:\Users\Rahul\Desktop\Compilers\src\cs553s2013\mylexer>go install
> is_digit.go go install command-line-arguments: open
> C:\Users\Rahul\Desktop\Compilers\bin\is_ digit.exe: Access is denied.

答案1

得分: 1

参见http://grokbase.com/t/gg/golang-nuts/135fyje5d9/go-nuts-go-build-access-is-denied-windows-7x64

绝对不知道为什么,但上述建议起作用了。在Windows 7上,必须启用“应用程序体验”Windows服务来解决此问题。

我之前禁用了这个服务,并且在我的项目二进制文件上看到了类似的奇怪的2-3分钟的“权限被拒绝”时间(在Windows资源管理器中查看$GOPATH/bin,通过alt+F2刷新后,二进制文件也会消失,这是由Eclipse + Goclipse构建的)。我注意到,在执行之后,二进制文件最终消失之前,它被更改为由某个未知用户拥有(在资源管理器中,它不是由编译用户、管理员甚至是SYSTEM拥有)。

我只能推测 - 也许Windows会保留任何在文件系统上的.exe文件,如果它在退出时没有向Windows内核发送某种未记录的“一切正常”状态,假设它“崩溃”了,因此应用程序体验服务可以将其作为诊断数据发送给Microsoft - 如果该服务被禁用,应用程序体验服务无法完成NTFS或资源管理器正在等待的任何握手,以允许文件被后续的编译覆盖。因此,golang .exe文件以提升的权限存在,由某个系统/未定义的用户拥有,无法被Eclipse删除,直到资源管理器执行某些操作将其标记为明确死亡。

英文:

See http://grokbase.com/t/gg/golang-nuts/135fyje5d9/go-nuts-go-build-access-is-denied-windows-7x64

Absolutely no idea why, but the above suggestion worked. One must enable the "Application Experience" windows service on Windows 7 to solve this issue.

I had this service disabled, and was seeing a similar strange 2-3 minute time of "Permission Denied" on my project's binary (the binary would also disappear after a refresh via alt+F2 of $GOPATH/bin, from a Windows Explorer view of the $GOPATH/bin where Eclipse + Goclipse was building my binary). I noticed that just after execution, and before the binary finally disappeared, it was changed to be owned by some unknown user (in Explorer, it isn't owned by the compiling user, Administrator, or even SYSTEM).

I can only speculate -- perhaps Windows keeps any .exe on the filesystem, if it has exited without some sort of undocumented 'all-OK' status to the windows kernel, assuming it 'crashed', so the Application Experience service can send it as diagnostic data to Microsoft -- and if that service is disabled, the Application Experience service can't finalize whatever handshake NTFS or Explorer is waiting for to allow the file to be overwritten by subsequent compiles. So the golang .exe sits there, with elevated permissions, with some system/undefined user, un-deleteable by Eclipse, until Explorer does something to mark it as definitely dead.

huangapple
  • 本文由 发表于 2013年1月25日 05:53:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/14511495.html
匿名

发表评论

匿名网友

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

确定