-
Notifications
You must be signed in to change notification settings - Fork 30k
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
process.cwd() symlink behavior is undocumented #45617
Comments
On Unix-like operating systems, libuv uses On Windows, libuv uses So if we're going to document this one, we'll want to be careful to get it right. Pinging teams that contain people that will know better than me: @nodejs/libuv @nodejs/platform-windows |
POSIX captures existing behavior so I'd say it's a good bet all UNIX-like platforms work that way. I've opened libuv/libuv#3828 to discuss the UNIX vs. Windows inconsistency. |
Somehow - this issue appeared to be a reason of a follow-up issues with devcontainers: which results in a problem with VS Code: and prevents to solve another problem caused by docker: Unfortunately neither So the only method which is supposed to give the real folder - does not work as expected. I'd prefer if process.cwd returns the actual folder and if you need realpath you should do something like fs.realpath(process.cwd( ) ) What do you think of this? |
also requested a flag to be added: #56288 |
As @Trott mentioned You could read the |
but that's what I mean, can't we introduce a new flag/option forcing node not to use this getcwd but to use something else? For example pwd in Linux? I still do not understand why exec('pwd') can return what we need, but process.cwd cannot.. May be we can route this logic on Unix systems somehow |
In a nutshell Since reading the env var is fragile I'd say this would be better addressed in the app. Is that not possible? |
well - indeed - that's possible , but it means that in my case for example - if I want to open some folder in a devcontainer in vscode, from a folder like
Which is still long way to go. Meanwhile at same time I clearly see something like: That's kind of idea why env variable can be better even if it's fragile. |
I guess my question is what changed that made this a problem now, since |
Oh.. i think it's a combination of some few factors. In my case it's an internal Docker problem - that it cannot mount somehow mounted folder ( folder is mount to wsl and I try to mount it to another container ), but it does with symlinked folder ( i have no clue why). At same time I understand that using symlinked CWD can be a problem for many tools like file watchers. However flags like
|
I'd say it's out of the question for node to use $PWD, gated on a flag or not. Native modules can call chdir(2) and that would not be visible to node. |
Originally posted by @romamik in #22602 (comment)
The text was updated successfully, but these errors were encountered: