-
Notifications
You must be signed in to change notification settings - Fork 31k
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
readdirSync of drive letter lists items of cwd #9378
Comments
Can reproduce on Win 7 x64 with Node.js 7 with additional observation: However, if |
Yep, forgot to mention that it's only when doing I haven't tested, but I assume the problem also exists with |
It seems that
I can't find this in the |
Oh, it makes sense then. The I would say that it's still a surprising behavior, and thus should be fixed. |
So, I’m not a frequent Windows user, but from the little experience I have with drive-specific working dirs, it seems like Node is behaving as expected? Maybe this should just be mentioned in the docs? |
I am not sure users expect from Node |
If I’m reading this issue correctly, there’s nothing shell-specific about this, which is kind of why Node is having this behaviour? I mean, yes, drive-specific wds are not very intuitive when first encountering them, but at least they are consistent… Also, two questions:
|
It seems you are right. So maybe this just could be added to |
I agree with @vsemozhetbyt . I would also argue, more importantly, that it's dependent on the drive you were on when starting node. So the behavior will not be the same for everyone. |
I believe it is not specific to particular command, but windows built-in behavior since ever. if you just type |
This is surprising Windows behavior, not Node behavior. What is surprising is that drive letters are not exactly like directory paths, and cannot be expected to work exactly the same. Drives (like Node is correct as it is: https://github.com/nodejs/node/blob/3c1e5b366f/lib/path.js#L170-L175 . Highlighting this in the docs would be great, I believe this is often unexpected for people without Windows background. |
I insist on the fact that the behavior depends on the drive the user was when running node.
yields different results than after
Same if I have an electron/nw.js app that users installed on different drives, or if I set a different That Windows is broken in the same way seems of little importance to me. Replicating the Windows behavior will break things for many people, and I'm pretty sure (almost) nobody relies on it. Of course, I may be wrong, but I doubt it.
I've been working on Windows for more than 10 years and have never encountered this (I knew about |
I just found out that Unix also has weirdnesses when using Here using oh-my-zsh on MacOS Sierra:
With this additional information, I agree that just adding a warning in the doc is more pertinent. |
@cosmo0 I think that doesn’t affect |
Link itself is a file, so that is the correct behavior, imo. |
@cosmo0 Can you show what you get when you run node from different drives? Before running node, make sure the cwd is set for both, by changing to the drive and |
Running I am using Powershell, not From
then from
As you can see, depending on where you run Your request of In Powershell:
Which leads to yet another behavior when using
|
The Note: |
I added the |
Apparently I both added and deleted the label 😄 |
According to this link changing location in PowerShell doesn't actually change the cwd for non-PowerShell commands. |
Has this issue been resolved? |
Don't think so, the behaviour still needs documenting. |
@gibfahn But in my computer, Eg. If my username is |
Yes, that's the expected behaviour. When you use C: :: cd to the current working directory in C:, in your case c:\Users\XadillaX\
cd Desktop :: Changes the C: cwd to c:\Users\XadillaX\Desktop
D: :: Changes to the current working directory in D:
dir C: :: Shows the contents of the cwd in C: , now c:\Users\XadillaX\Desktop
dir C:\ :: Shows the contents of the root of C It should be documented, but it's a Windows oddity, not a node one. You just have to remember that D:\> C:
C:\Users\gib> cd Desktop
C:\Users\gib\Desktop> D:
D:\> dir C:
Volume in drive C has no label.
Volume Serial Number is E0D4-8E7B
Directory of C:\Users\gib\Desktop
04/05/2017 11:46 AM <DIR> .
04/05/2017 11:46 AM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 71,552,552,960 bytes free
D:\> dir C:\
Directory of C:\
04/12/2017 10:12 AM <DIR> Users
05/03/2017 10:32 AM <DIR> Windows
2 File(s) 4,112 bytes
12 Dir(s) 71,552,552,960 bytes free |
Add note to fs.md and path.md about Windows using per-drive current working directory. Fixes: nodejs#9378
I've created a PR for doc update here: #13330 I think that node behaves here correctly. It gives the same results (on both cmd and powershell) as this simple prog: #include <windows.h>
#include <iostream>
int main() {
int main() {
TCHAR buffer[1024];
GetFullPathName("C:", 1024, buffer, nullptr);
std::cout << "c: " << buffer << "\n";
GetFullPathName("D:", 1024, buffer, nullptr);
std::cout << "d: " << buffer << "\n";
} |
Add note to fs.md and path.md about Windows using per-drive current working directory. Fixes: #9378 PR-URL: #13330 Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
ReaddirSync behavior depends on the current working directory (cwd/pwd) if we pass a drive letter with or without a trailing "".
It's very easy to reproduce. Here, I am on "d:" drive, and I have a "d:\Temp" folder, containing "A" and "B" sub-folders.
It's a very suprising behavior, and more importantly, it's not documented if expected.
The text was updated successfully, but these errors were encountered: