Skip to content
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

fs APIs don't understand AppExecLink reparse points on Windows #36790

Open
TylerLeonhardt opened this issue Jan 4, 2021 · 3 comments
Open

fs APIs don't understand AppExecLink reparse points on Windows #36790

TylerLeonhardt opened this issue Jan 4, 2021 · 3 comments
Labels
fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. windows Issues and PRs related to the Windows platform.

Comments

@TylerLeonhardt
Copy link

TylerLeonhardt commented Jan 4, 2021

  • Version: v14.15.3
  • Platform: Windows
  • Subsystem: fs

What steps will reproduce the bug?

  1. Install an app from the Microsoft Store like PowerShell, PowerShell Preview, or Python.
  2. Run the following in Node.js:
// 1
fs.statSync("C:\\Users\\tyleonha\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe")

// 2
fs.existsSync("C:\\Users\\tyleonha\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe")

How often does it reproduce? Is there a required condition?

100% repro rate

What is the expected behavior?

// 1
Stats {
  dev: 2191433689,
  mode: 33206,
  nlink: 1,
  uid: 0,
  gid: 0,
  rdev: 0,
  blksize: 4096,
  ino: 2251799813690117,
  size: 6,
  blocks: 0,
  atimeMs: 1609796639210.8977,
  mtimeMs: 1609794509320.4253,
  ctimeMs: 1609794563739.3364,
  birthtimeMs: 1609794509315.4263,
  atime: 2021-01-04T21:43:59.211Z,
  mtime: 2021-01-04T21:08:29.320Z,
  ctime: 2021-01-04T21:09:23.739Z,
  birthtime: 2021-01-04T21:08:29.315Z
}

// 2
true

What do you see instead?

// 1
Uncaught:
Error: EACCES: permission denied, stat 'C:\Users\tyleonha\AppData\Local\Microsoft\WindowsApps\pwsh.exe'
    at Object.statSync (fs.js:1086:3) {
  errno: -4092,
  syscall: 'stat',
  code: 'EACCES',
  path: 'C:\\Users\\tyleonha\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe'
}

// 2
false

Additional information

This only seems to happen with AppExecLink reparse points on Windows. Regular SymbolicLinks are fine on Windows and give the expected behavior.

Also, fs.lstatSync works with these AppExecLink's which I'm guessing is because lstat operates on the symlnk and not the file that the symlnk points to.

Related issues:
#33024
microsoft/vscode#95828

@TylerLeonhardt TylerLeonhardt changed the title fs APIs don't really understand AppExecLink reparse points on Windows fs APIs don't understand AppExecLink reparse points on Windows Jan 4, 2021
@TylerLeonhardt
Copy link
Author

This appears to be a workaround (using fs.readlinkSync):

> fs.statSync(fs.readlinkSync("C:\\Users\\tyleonha\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe"))

Stats {
  dev: 2191433689,
  mode: 33206,
  nlink: 1,
  uid: 0,
  gid: 0,
  rdev: 0,
  blksize: 4096,
  ino: 562949953571058,
  size: 280456,
  blocks: 552,
  atimeMs: 1609813951771.307,
  mtimeMs: 1606342749993.0173,
  ctimeMs: 1606360363788.224,
  birthtimeMs: 1606342735014.0168,
  atime: 2021-01-05T02:32:31.771Z,
  mtime: 2020-11-25T22:19:09.993Z,
  ctime: 2020-11-26T03:12:43.788Z,
  birthtime: 2020-11-25T22:18:55.014Z
}

@targos targos added the fs Issues and PRs related to the fs subsystem / file system. label Jan 5, 2021
@RaisinTen RaisinTen added the windows Issues and PRs related to the Windows platform. label Jan 6, 2021
@jasnell
Copy link
Member

jasnell commented Mar 5, 2021

The fs.readlinkSync workaround is likely just giving you the details of the SystemUDPLauncher.exe and not the pwsh.exe file here. Hmm... definitely thinking this is something that needs to be fixed at the libuv level.

/cc @nodejs/libuv

@jasnell jasnell added the libuv Issues and PRs related to the libuv dependency or the uv binding. label Mar 5, 2021
@vtjnash
Copy link
Contributor

vtjnash commented Jan 18, 2023

It throws EACCES, because Win32 as apparently designed, forbids access to stat on this file #33024 (comment). Perhaps something like https://github.com/libuv/libuv/pull/3268/files#r1007238152 would work though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

5 participants