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
fix: github issue #4439: case insensitive compare of file paths. #4440
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we can add a test for this, after all, tests are also running on Windows. There is a special test file just for loadConfigFile
, or maybe a test case in the tests/cli folder?
Codecov Report
@@ Coverage Diff @@
## master #4440 +/- ##
==========================================
- Coverage 98.77% 98.74% -0.03%
==========================================
Files 205 205
Lines 7326 7329 +3
Branches 2079 2080 +1
==========================================
+ Hits 7236 7237 +1
- Misses 33 34 +1
- Partials 57 58 +1
Continue to review full report at Codecov.
|
yeah, I've been having a similar conversation over here: rollup/plugins#1134. I can certainly use that trick to make all the rollup tests fails in the same way. Just not sure how to do that in the CI VM... |
Note there may be one more error lerking in the code because when I force the default drive letter to be wrong (using the tricks I mentioned in rollup/plugins#1134, then PS: and this is after I patched the older version 2.67.1 of |
I wonder if this is a node.js bug? |
btw @lukastaegert
is also responsible for this issue: #4465 (confirmed) as well as likely this one: #4446 (not confirmed) but in this case both variables represent different paths, one is the 'real path', and the other the 'mounted path' (subst). this PR will not address this. I wonder if there's a better solution to fix both issues? I also wonder now how this comparison logic works on mounted drives on macos/linux. 🤔 I also tried to figure out why this comparison is in place, but didn't get anywhere. the entire logic of reading just a config file seems to be overly complicated and convoluted on first sight. (not judging). I imagine it grew organically without much refactoring and one of the obstacles is also trying to read many formats it also appears that this is also a good candidate for a v3 refactoring (regarding proper cjs and esm parity with node.js, which it looks like rollup is doing it's own thing so to speak). |
I got the same error and found that the rollup/cli/run/loadConfigFile.ts Lines 106 to 124 in 931a199
In the problematic scenario the resolvedFileName and the fileName differ in case.
UPD: I have prepared #4501 to demonstrate an alternative fix. @lovettchris, @dnalborczyk, please take a look. |
Closing this in favor of #4501, which should solve the same issue but I think is a more general solution. |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
resolves #4439
Description
On windows the string returned from
await fs.realpath(fileName)
might contain lower case drive letter while the string returned frompath.resolve(__dirname, ...)
can return a different case, which causes direct string comparisons using===
to fail. This fix adds a win32 specific implementation of a helper functionisSamePath
that ensures the comparison is case insensitive on a win32 platform.