Skip to content

Add support for extracting environment from xonsh.#201036

Merged
Tyriar merged 2 commits intomicrosoft:mainfrom
jaraco:feature/xonsh-env
Dec 18, 2023
Merged

Add support for extracting environment from xonsh.#201036
Tyriar merged 2 commits intomicrosoft:mainfrom
jaraco:feature/xonsh-env

Conversation

@jaraco
Copy link
Contributor

@jaraco jaraco commented Dec 16, 2023

Closes #200374.

@jaraco
Copy link
Contributor Author

jaraco commented Dec 16, 2023

I haven't tested this change beyond confirming that xonsh -i -l -c '$[<command>]' works syntactically:

 @ xonsh -i -l -c '$[echo foo]'
foo

Is there a way I can get a build with the change to confirm it fixes the reported issue?

@jaraco
Copy link
Contributor Author

jaraco commented Dec 17, 2023

I read the instructions and figured out how to make a local build of VSCode and ran ./scripts/code.sh, but I couldn't replicate the failure on main. I presume the issue is that the code path isn't triggered when launched from the CLI. I thought I might be able to simulate the non-shell environment by launching with env -i PATH=$PATH ./scripts/code.sh, but even then, the issue doesn't replicate.

Next, I read the code and learned about --force-user-env and using that I was able to replicate the failure. With the patch, the failure still occurs, so I'll need to investigate further.

@jaraco
Copy link
Contributor Author

jaraco commented Dec 17, 2023

By running with --log trace, I can see the command that's being run:

[main 2023-12-17T16:38:29.119Z] getUnixShellEnvironment#shell /Users/jaraco/.local/bin/xonsh
[main 2023-12-17T16:38:29.119Z] getUnixShellEnvironment#spawn ["-i","-l","-c"] $['/Users/jaraco/code/microsoft/vscode/.build/electron/Code - OSS.app/Contents/MacOS/Electron'  -p '"280993a1c165" + JSON.stringify(process.env) + "280993a1c165"']
@jaraco
Copy link
Contributor Author

jaraco commented Dec 17, 2023

When I run that command manually

 @ xonsh -c """$['/Users/jaraco/code/microsoft/vscode/.build/electron/Code - OSS.app/Contents/MacOS/Electron'  -p '"280993a1c165" + JSON.stringify(process.env) + "280993a1c165"']"""

it fails thus:

image

Text in that image:

Unable to find Electron app at /Users/jaraco/code/microsoft/vscode/"280993a1c165" + JSON.stringify(process.env) + "280993a1c165"

Cannot find module '/Users/jaraco/code/microsoft/vscode/"280993a1c165" + JSON.stringify(process.env) + "280993a1c165"'
Require stack:
- /Users/jaraco/code/microsoft/vscode/.build/electron/Code - OSS.app/Contents/Resources/default_app.asar/main.js
-
@jaraco
Copy link
Contributor Author

jaraco commented Dec 17, 2023

I haven't yet figured out why the invocation of Electron is failing but in c62c575, I replaced the electron invocation with a native JSON rendering of the environment in xonsh, and I've confirmed this approach fixes the issue.

Is this approach acceptable?

Is there any idea why Electron is failing the way it is?

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the output is identical to the JSON output (or at least parsed in the same way in node), the current approach is fine. It's probably better actually as that way we don't need to launch node.

Let's merge this, please let me know if there are problems with it when it ships as the only way to test this properly is to get a real build post-merge and try launching from the dock.

@Tyriar Tyriar added this to the December / January 2024 milestone Dec 18, 2023
@Tyriar Tyriar enabled auto-merge December 18, 2023 15:37
@Tyriar Tyriar merged commit 60017c3 into microsoft:main Dec 18, 2023
@jaraco jaraco deleted the feature/xonsh-env branch December 18, 2023 21:09
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants