-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
os: reorder get temp environment variable for windows #42300
Conversation
Welcome, @chouzz, and thanks for the pull request. Assuming this doesn't cause any existing tests to fail, we'll want to add a test for this, probably in |
cc @nodejs/platform-windows |
Hi, it's my first contributions. Fortunately,it doesn't affect existing tests. I will add test for this. |
According to windows document, the temp direcotry should check $TMP first, after that, check $TEMP, or node will get different temp directory compared with c/c++ program if user have different path for $TMP and $TEMP in windows. Refs: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha
03db1b0
to
3ed2260
Compare
It should cause current |
Labelling this as a semver-major since this is breaking. Not sure if it's worth the breakage though because other modules might already be depending on this behaviour. |
GitHub actions don't currently run tests on Windows as the tests were not consistently passing. All the coverage jobs (including on Jenkins) ignore test failures -- I don't recall why. |
Thanks for clarifying.
@RaisinTen Could you please clearfiy which modules depend on this? As I can see, some modules may depending on this, also may not depending on this. As for me, this is a bug. I have a server program written by c/c++ will create temp file in temp directory, and client base on nodejs will get the file, in this case, I will get "can't find temp file" error. Becase server side create temp file in $TMP, but client get temp file in $TEMP. The problem only happens if user have different paths for $TMP and $TEMP. On the other hand, $TMP and $TEMP are same path by default(
|
I don't know of a specific module name but someone just like you might have already written a program that does the same exact thing, except it has been written by keeping in mind that
Did you consider passing the absolute file paths from the server to the client? That way, the client would be able to use the right file paths, regardless of the value of the environment variables.
I disagree. Programs are free to choose any sequence they desire. See https://devblogs.microsoft.com/oldnewthing/20150417-00/?p=44213
I also noticed that Python uses a different sequence - https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir
|
I saw nodejs have same logic for $TMP and $TEMP 10 years ago. And it changed 7 years ago, then it try to get $TEMP before $TMP in windows.
OK. I also see the wiki said in DOS:
https://en.wikipedia.org/wiki/Environment_variable But seems all languages based on win32 api will get $TMP first. So the question is that do we need to change this order? Should node be consistent with them? |
The order was changed in nodejs/node-v0.x-archive#5083 |
The issue had linked to windows
|
Feel free to close the PR if you think it's not suitable. @RaisinTen @targos My program can solve this problem easily. |
Yea, since programs are not mandated to follow a specific sequence, I think the current behaviour is alright and since you mentioned that the problem this PR was trying to solve can already be solved by your program, there's no reason to keep this PR open anymore, so I'm closing it. Thank you for the PR regardless!
Good to know. :) |
According to windows document, the temp direcotry should check $TMP
first, after that, check $TEMP, or node will get different temp
directory compared with c/c++ program if user have different path
for $TMP and $TEMP in windows.
Refs: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha