-
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
require fails to load 'package.json' when the module path contains Chinese characters on Windows. #2236
Comments
just confirmed. The regression appeared with v2.2.0 |
The module resolution fails because it cannot read the |
@bnoordhuis @trevnorris this is really bad and a huge regression from pre 2.2.0 io.js. I can reproduce the require call to fail easily by having a index.js file sit inside a folder with german umlauts (or any other non ascii character). This might be less critical for use cases of io.js in server environments and Mac/Linux, but dont forget that e.g. Electron (the shell of the atom editor: https://github.com/atom/electron) is using io.js for all node matters and you can easily end up installing it on a Windows path with special characters. From looking at the code, it seems to fail inside InternalModuleReadFile (https://github.com/bnoordhuis/io.js/blob/master/src/node_file.cc#L443), maybe in the fopen call. That is also the only place where fopen is being used. Other fs calls like the internal stat call are not failing like that. |
@bnoordhuis Should Windows use |
I'd use uv_fs_open() + uv_fs_read(). |
This does seem to be rather bad, I'd consider this a candidate for blocking the 3.1 release, thoughts? |
It's not a regression in v3.x (because it's older than that) but fixing it of course won't hurt: #2377 |
Thanks for the prompt fix! |
I need a volunteer that's affected by this to test the changes in #2377. The current working hypothesis is that it's related to the code page. |
@bnoordhuis I verified that your change fixes the issue for me. My test case is this:
With your fix I can load the module and before I could not. I am not sure about the theory this is code page related. My windows installation is set to english locale. Please let me know if you need more infos of my windows installation to reproduce. I can also attach my sample to see if you can repro. |
@bnoordhuis it fails for me without the fix and passes with. Failing output: C:\GitDevelopment\iojs-bnoordhuis\Release>iojs.exe C:\GitDevelopment\iojs-bnoordhuis\test\parallel\test-require-unicode.js Error: Cannot find module 'C:\GitDevelopment\iojs-bnoordhuis\test\tmp\õ©¡µûçþø«Õ¢ò' |
Okay, thanks. Perhaps it's a compatibility issue with newer Windows versions. Our CI consists of Windows Server 2008 and 2012. |
@bnoordhuis from what I gather, this should get you utf8 mode fopen(file, "r+, ccs=UTF-8") With unspecified encoding, the system should fall back to the user's locale. Maybe that fallback behaviour has changed in recent Windows versions. https://msdn.microsoft.com/en-us/library/yeby3zcb.aspx |
Fix a regression that was introduced in commit 1bbf8d0 ("lib: speed up require(), phase 2") where file paths with Unicode characters fail to load on Windows. Fixes: nodejs#2236 PR-URL: nodejs#2377 Reviewed-By: Bert Belder <[email protected]>
Should be fixed by a593cb7, /cc @Fishrock123. |
Fix a regression that was introduced in commit 1bbf8d0 ("lib: speed up require(), phase 2") where file paths with Unicode characters fail to load on Windows. Fixes: nodejs#2236 PR-URL: nodejs#2377 Reviewed-By: Bert Belder <[email protected]>
Reproduce steps:
And the content of
package.json
:require("<Chinese-path>")
in iojs, then ErrorError: Cannot find module XXX
will arise.It fails on iojs v2.4 and v3.0 rc4, but works on v1.6, I believe a regression issue. What's more, it seems only fails to read the
package.json
file. If we require a absolute js path(<Chinese-path>/main.js
), it loads the module well.The text was updated successfully, but these errors were encountered: