You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
L44 saves this script using UTF-8. On Windows, Command Prompt determines the encoding used to decode and interpret batch files based on the current system "Codepage", which is usually not UTF-8.
This leads to the following situations:
The generated script contains the full paths of node.exe and yarn.cjs, so if either the node or yarn directory contains non-ASCII characters, this bug will occur.
For node, the error will be The System Cannot Find The Path Specified.
For yarn, the error will be Error: Cannot find module '<wrongly encoded path>\yarn.cjs'.
ASCII characters are compatible with all codepages. For paths containing only ASCII characters, although the codepage is diverse, this bug will not occur.
In addition, the following points are worth noting:
This bug is Windows specific. Only Command Prompt on Windows decodes and interprets scripts using encodings other than UTF-8.
To fix this bug, Yarn must detect the current codepage of the system, and then select the corresponding encoding to save the script. Unfortunately, node does not provide a corresponding API, so implementing codepage detection requires depending a C++ binding package, which is not suitable for Yarn.
This issue is just to clarify the current situation and to remind latecomers, so feel free to close this issue.
Temporary workaround: currently, the best solution is to move both node.exe and yarn.cjs to paths containing only ASCII characters.
The text was updated successfully, but these errors were encountered:
Self-service
Describe the bug
Cannot spawn
yarn
(eg. usingnode:child_process
or any other spawn library) if there're non-ASCII characters (eg.å
orあ
) in project path.To reproduce
Produces the following output:
Environment
Additional context
This bug is caused by the following code:
berry/packages/yarnpkg-core/sources/scriptUtils.ts
Lines 41 to 45 in 873e9d8
L44 saves this script using UTF-8. On Windows, Command Prompt determines the encoding used to decode and interpret batch files based on the current system "Codepage", which is usually not UTF-8.
This leads to the following situations:
node.exe
andyarn.cjs
, so if either the node or yarn directory contains non-ASCII characters, this bug will occur.The System Cannot Find The Path Specified
.Error: Cannot find module '<wrongly encoded path>\yarn.cjs'
.In addition, the following points are worth noting:
This bug is Windows specific. Only Command Prompt on Windows decodes and interprets scripts using encodings other than UTF-8.
This issue is basically the same as [Bug] Yarn install/pnp fails if there are non-ASCII symbols in the path #2397. While there is fix(core): add missing setlocal in the cmd file for Windows #2499 for fixing [Bug] Yarn install/pnp fails if there are non-ASCII symbols in the path #2397, I believe fix(core): add missing setlocal in the cmd file for Windows #2499 doesn't actually fix this.
This bug cannot be fixed from the yarn side.
To fix this bug, Yarn must detect the current codepage of the system, and then select the corresponding encoding to save the script. Unfortunately, node does not provide a corresponding API, so implementing codepage detection requires depending a C++ binding package, which is not suitable for Yarn.
This issue is just to clarify the current situation and to remind latecomers, so feel free to close this issue.
node.exe
andyarn.cjs
to paths containing only ASCII characters.The text was updated successfully, but these errors were encountered: