Skip to content
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

spawn comes with a broken locale and $LANG #142857

Closed
artagnon opened this issue Feb 11, 2022 · 8 comments
Closed

spawn comes with a broken locale and $LANG #142857

artagnon opened this issue Feb 11, 2022 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug extension-host Extension host issues insiders-released Patch has been released in VS Code Insiders macos Issues with VS Code on MAC/OS X regression Something that used to work is now broken verified Verification succeeded
Milestone

Comments

@artagnon
Copy link

This is most probably a bug in:

$ code -v
1.65.0-insider
bb221a61d29deabd99ee9431736d04f2175cb596
x64

as it cannot be reproduced on 1.64.

My system locale is:

$ locale
LANG="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_CTYPE="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_ALL=

I observed the problem in James-Yu/LaTeX-Workshop#3081 -- it uses a package called 'cross-spawn' (which boils down to an Electron spawn) to spawn a subprocess. Now, if that certain subprocess checks for a valid locale, then the task fails. This is because spawn seems to use LANG=fr, which is an invalid version of LANG=fr_FR.UTF-8. I found this out by stepping through the code. I can confirm that the problem is not in the cross-spawn package itself, as the same versions of James-Yu/LaTeX-Workshop were operating on both versions of vscode.

I'm a little tired, and don't have the motivation to cook up a reduced case at the moment, but please feel free to ask for more information.

@sihde
Copy link

sihde commented Feb 14, 2022

This could be the root cause of dotnet/vscode-dotnet-runtime#397 as well; the dotnet-runtime extension is failing because tar errors out with "Failed to set default locale". It seems recent Code Insiders builds for MacOS may have picked up a change in the Electron spawn code which corrupts the $LANG variable.

@StephenWeatherford
Copy link

Note: This is a severe regression for all extensions that depend on the https://github.com/dotnet/vscode-dotnet-runtime. From the investigation there (thanks @sihde!):

  1. Does not repro in released version 1.64.2 but does repro in 1.65.x-insiders
  2. Running the dotnet install script manually suceeds (from outside vs code and in the vscode terminal) but fails when run by the vscode-dotnet-runtime extension (see https://github.com/dotnet/vscode-dotnet-runtime/blob/fe54a616a8a8df2a507028474a56b5b5423de734/vscode-dotnet-runtime-library/src/Acquisition/AcquisitionInvoker.ts#L39)

@tamuratak
Copy link
Contributor

Version: 1.65.0-insider (Universal)
Commit: 50089c3
Date: 2022-02-14T05:17:15.582Z
Electron: 16.0.8
Chromium: 96.0.4664.110
Node.js: 16.9.1
V8: 9.6.180.21-electron.0
OS: Darwin arm64 20.6.0

I am one of the maintainers of LaTeX Workshop.

I have confirmed that when starting VS Code Insiders from Dock, the environment variable LANG of the extension host is set as ja. On the stable version of VS Code 1.64.2, it is undefined.

When starting VS Code Insiders from Terminal.app, it is set as ja_JP.UTF-8.

The root cause is that ja is NOT a valid locale. VS Code Insiders picks an invalid locale as a default locale.

$ locale -a | grep ja
ja_JP.SJIS
ja_JP
ja_JP.UTF-8
ja_JP.eucJP

@sihde
Copy link

sihde commented Feb 14, 2022

I have confirmed that when starting VS Code Insiders from Dock, the environment variable LANG of the extension host is set as ja. On the stable version of VS Code 1.64.2, it is undefined.

Thanks @tamuratak . This allows me to reproduce the .NET installation error message in dotnet/vscode-dotnet-runtime#397:

$ LANG=ja tar xf /dev/null
tar: Failed to set default locale

Same for LANG=en, etc. This is the same error that tar emits when the .NET installation fails.

I also confirmed that when starting VS Code Insiders from the command line (where, in my case, LANG=en_US.UTF-8), it works correctly.

So, it seems this is breaking multiple extensions.

@tamuratak
Copy link
Contributor

@rzhao271 It might be related to #141095

@rzhao271 rzhao271 self-assigned this Feb 15, 2022
@rzhao271 rzhao271 added regression Something that used to work is now broken bug Issue identified by VS Code Team member as probable bug labels Feb 15, 2022
@rzhao271 rzhao271 added this to the February 2022 milestone Feb 15, 2022
rzhao271 added a commit that referenced this issue Feb 15, 2022
@deepak1556
Copy link
Collaborator

\closedWith e8cfc68

@deepak1556 deepak1556 added extension-host Extension host issues macos Issues with VS Code on MAC/OS X labels Feb 15, 2022
@rzhao271 rzhao271 added the author-verification-requested Issues potentially verifiable by issue author label Feb 24, 2022
@artagnon
Copy link
Author

/verified

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug extension-host Extension host issues insiders-released Patch has been released in VS Code Insiders macos Issues with VS Code on MAC/OS X regression Something that used to work is now broken verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants
@artagnon @sihde @deepak1556 @weinand @StephenWeatherford @rzhao271 @tamuratak and others