-
Notifications
You must be signed in to change notification settings - Fork 18k
os/exec: calling Command on file with UWP reparse point fails with "file does not exist" #42919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@gopherbot add OS-Windows |
/cc /cc @bradfitz @ianlancetaylor @alexbrainman |
It caused by that findExecutable uses os.Stat instead of os.Lstat. os.Lstat resolve reparse-points. diff --git a/src/os/exec/lp_windows.go b/src/os/exec/lp_windows.go
index 9ea3d76575..12c7e04e63 100644
--- a/src/os/exec/lp_windows.go
+++ b/src/os/exec/lp_windows.go
@@ -15,7 +15,7 @@ import (
var ErrNotFound = errors.New("executable file not found in %PATH%")
func chkStat(file string) error {
- d, err := os.Stat(file)
+ d, err := os.Lstat(file)
if err != nil {
return err
} This fixes the issue the program can not execute python.exe, but the python.exe exit with 9009 exit code. Probably, it is another issue. |
Yes - I alluded to that in the original report but should have called it out better:
A naive thought here would be to consider passing As such, I see the following issues:
|
Does https://go-review.googlesource.com/c/go/+/384160 fixes this bug? If yes, please, help review the CL 384160. Alternatively send your own fix (if you know how to fix it) Thank you. Alex |
IO_REPARSE_TAG_APPEXECLINK are types of links that are created when installing an application via the Windows App Store. The location of these links is added to the Windows PATH and the system can resolve them. This adds support for these links so go can resolve them. Fixes golang#42919
IO_REPARSE_TAG_APPEXECLINK are types of links that are created when installing an application via the Windows App Store. The location of these links is added to the Windows PATH and the system can resolve them. This adds support for these links so go can resolve them. Fixes golang#42919
@alexbrainman @JanDeDobbeleer The PR modifies Changing |
@sachinjoseph I agree. I'm looking for a new way to handle this in the correct spot but truth be told, it's a bit of a maze 😃. The problem is that in go lookpath can't resolve this. So it needs to be fixed somewhere over there ideally. |
IO_REPARSE_TAG_APPEXECLINK are types of links that are created when installing an application via the Windows App Store. The location of these links is added to the Windows PATH and the system can resolve them. This adds support for these links so go can resolve them. Fixes golang#42919
IO_REPARSE_TAG_APPEXECLINK are types of links that are created when installing an application via the Windows App Store. The location of these links is added to the Windows PATH and the system can resolve them. This adds support for these links so go can resolve them. Fixes golang#42919
@sachinjoseph decided to add an explicit call to |
@JanDeDobbeleer Great! How do I test this? Can I simply clone your fork/branch and build it? Do I need to enable CGO? Were you able to launch |
@sachinjoseph yes, you can simply take that branch and build it, doesn't need cgo. I didn't validate winget but theoretically that should just work. |
@JanDeDobbeleer Let me try that |
@JanDeDobbeleer
Test.gopackage main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
)
func main() {
path := filepath.Join(os.Getenv("LOCALAPPDATA"), "Microsoft\\WindowsApps\\winget.exe")
// path = "C:\\Program Files\\Git\\cmd\\git.exe"
cmd := exec.Command(path, "--version")
output, err := cmd.Output()
fmt.Println(string(output))
fmt.Println(err)
fmt.Println("\nStat-ing the file")
f, err := os.Stat(path)
fmt.Println(f)
fmt.Println(err)
} Go 1.18pwsh> go version
go version go1.18 windows/amd64
pwsh> go run test.go
exec: "C:\\Users\\username\\AppData\\Local\\Microsoft\\WindowsApps\\winget.exe": file does not exist
Stat-ing the file
<nil>
CreateFile C:\Users\username\AppData\Local\Microsoft\WindowsApps\winget.exe: The file cannot be accessed by the system.
pwsh> @JanDeDobbeleer's branchpwsh> .\go.exe version
go version devel go1.19-aaf7044240 Tue Apr 19 21:19:47 2022 +0200 windows/amd64
pwsh> .\go.exe run test.go
v1.3.692-preview
<nil>
Stat-ing the file
<nil>
CreateFile C:\Users\username\AppData\Local\Microsoft\WindowsApps\winget.exe: The file cannot be accessed by the system.
pwsh>
|
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
@qmuntal can you, please, see if https://go-review.googlesource.com/c/go/+/452375 looks reasonable to you? Rob approved my CL, but I would not trust myself with that change. The CL uses some undocumented logic that @JanDeDobbeleer discovered. It appears to work on my Windows 10. This is not urgent since we have to wait for Go source tree to open for Go 1.21 development anyway. Thank you. Alex |
Please, review @JanDeDobbeleer https://go-review.googlesource.com/c/go/+/384160 instead. He copied all changes from my https://go-review.googlesource.com/c/go/+/452375 and I abandoned my CL. Thank you. Alex |
Sure! |
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
Change https://go.dev/cl/460595 mentions this issue: |
I think the problem here is more fundamental than just I have mailed an alternative approach in CL 460595, which attempts to generalize the solution by treating non-symlink reparse points as irregular files (instead of treating all reparse points like symlinks as we currently do). |
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
This change adds support for AppExecLinks files, like C:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.exe The python3.exe can be installed by following these https://www.microsoft.com/store/productId/9PJPW5LDXLZ5 instructions. The executable is added to your PATH and can be called from command line, like `python3 --version`. Calling GetFileAttributesEx on python3.exe returns FileAttributes with FILE_ATTRIBUTE_REPARSE_POINT set. And os.Stat attempts to follow the link. But Microsoft does not provide any link target for AppExecLinks files (see dotnet/runtime#58233 (comment) ), and Go should treat AppExecLinks as normal files and not symlinks. This CL adjusts os.Stat implementation to return normal file os.FileInfo for AppExecLinks files instead of symlinks. The AppExecLinks files are recognised as they return ERROR_CANT_ACCESS_FILE from CreateFile call. The trick is not documented anywhere. Jan De Dobbeleer discovered the trick. Also dotnet/runtime#58233 appears to also use ERROR_CANT_ACCESS_FILE to distinguish AppExecLinks files. The CL also adds new tests. The CL is an extended copy of the Jan De Dobbeleer https://go-review.googlesource.com/c/go/+/384160 CL. Fixes golang#42919 Change-Id: I8b5a26d0cac7882d3445393d26b182ad31cd753b
Windows 10 ships with some 0 length files in
C:\Users\<User>\AppData\Local\Microsoft\WindowsApps
with special reparse points which when run trigger the windows app store app to be launched.Once installed, the same files result in the installed app to be run going forward. For instance, Windows 10 ships with python3.exe which is in fact a link to python3.8 available on the Windows App Store.
C:\Users\<User>\AppData\Local\Microsoft\WindowsApps
happens to be on the PATH by default so once installed, the python3 interpreter should be invoked. However, when trying to run the same through Go'sexec.Cmd
we get afile does not exist
error (see below for simple repro).The main issue seems to be a call to
os.Stat
from theexec.Cmd
run path.os.Stat
on windows doesn't passsyscall.FILE_FLAG_OPEN_REPARSE_POINT
resulting in the error (unlike Lstat).What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Windows 10
go env
OutputWhat did you do?
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: