Skip to content

[NODERAWFS] Fix getcwd() on Windows - #27738

Merged
sbc100 merged 2 commits into
emscripten-core:mainfrom
sbc100:fix_getcwd_noderawfs
Sep 17, 2026
Merged

sbc100 merged 2 commits into
emscripten-core:mainfrom
sbc100:fix_getcwd_noderawfs

Conversation

@sbc100

@sbc100 sbc100 commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

In upstream musl, getcwd() checks buf[0] != '/' to detect the Linux kernel's (unreachable) prefix returned by sys_getcwd. Emscripten's __syscall_getcwd never returns (unreachable), and under NODERAWFS on Windows process.cwd() returns paths starting with a drive letter (e.g. C:\...) or UNC prefix (\\...), which caused getcwd() to fail with ENOENT.

Skip the buf[0] != '/' check on Emscripten and add a @crossplatform test_noderawfs_getcwd test so it runs on Windows CI.

Fixes: #25291

In upstream musl, `getcwd()` checks `buf[0] != '/'` to detect the
Linux kernel's `(unreachable)` prefix returned by `sys_getcwd`.
Emscripten's `__syscall_getcwd` never returns `(unreachable)`, and under
`NODERAWFS` on Windows `process.cwd()` returns paths starting with a
drive letter (e.g. `C:\...`) or UNC prefix (`\\...`), which caused
`getcwd()` to fail with `ENOENT`.

Skip the `buf[0] != '/'` check on Emscripten and add a `@crossplatform`
`test_noderawfs_getcwd` test so it runs on Windows CI.

Fixes: emscripten-core#25291
@sbc100
sbc100 force-pushed the fix_getcwd_noderawfs branch from 967d2cb to 8525ddc Compare September 17, 2026 19:14
Comment thread system/lib/libc/musl/src/unistd/getcwd.c Outdated
Co-authored-by: Alon Zakai <alonzakai@gmail.com>
@sbc100
sbc100 merged commit 88e32e4 into emscripten-core:main Sep 17, 2026
7 of 24 checks passed
@sbc100
sbc100 deleted the fix_getcwd_noderawfs branch September 17, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getcwd() using NODERAWFS fails when node is running on a windows host.

2 participants