-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Restore UseTerminalToGetActivatedEnvVars experiment #13071
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
Comments
Concerns with hidden terminal approachThere are been some concerns with using terminals if we don't absolutely need them. For eg. // Sometimes the terminal takes some time to start up before it can start accepting input.
await new Promise(resolve => setTimeout(resolve, 100)); protected async waitForCommandToProcess(_shell: TerminalShellType) {
// Give the command some time to complete.
// Its been observed that sending commands too early will strip some text off in VS Code Terminal.
await sleep(500);
} Handling temporary terminals, disposing them correctly, disposing the temporary files created to extract output, are also a few additional things to lookout for. Spike to decide whether to go with spawning processes or use hidden terminals to get the infoOne main issue with using spawning processes is that we only do it in the default shells for now - not the one that user has selected. IOW it's not running under the same shell that the actual terminal will be, which can be confusing for users. // The shell under which we'll execute activation scripts.
const defaultShells = {
[OSType.Windows]: { shell: 'cmd', shellType: TerminalShellType.commandPrompt },
[OSType.OSX]: { shell: 'bash', shellType: TerminalShellType.bash },
[OSType.Linux]: { shell: 'bash', shellType: TerminalShellType.bash },
[OSType.Unknown]: undefined
}; The following needs further investigation:
Using hidden terminals will make sure the activation scripts will run in the exact same environment that would other wise run when users run their code. So users can debug failing commands easily by just using the active terminal. Right now they can't debug why a command failed in the process. cc @int19h |
For Unicode issues, we should be able to control the output encoding, since we control the environment, and can set Spawning the shell directly should be no different from it being run in the terminal wrt initialization/activation, if we do everything correctly. This means respecting "shell" and "shellArgs" settings, in particular (e.g. The issue with group policy restrictions, or really any other configuration problems with a particular shell, mean that we can't hardcode that one shell, even for automated tools. There are other issues with this, anyway - moreso on non-Windows platforms where shells handle stuff like per-user environment variables (and so us using a different one means a different environment). But this, again, basically just means respecting "shell". So the biggest sticking point is that some activation scripts appear to require a tty. I don't believe that to be the case for conda - definitely not for But if pyenv and/or pipenv require a tty in principle (i.e. not just because of the way we are using them), there would be no way to avoid a terminal for those. And if we have it in the picture, we might as well use it uniformly for conda etc as well. Still, there ought to be a better way to reliably use that, which doesn't require introducing artificial delays to avoid synchronization issues. Maybe there's something in the |
However, there's also |
For PYENV_VERSION=2.7.14 pyenv exec python ... |
@int19h Found issue #11862, where the environment required tty. The user wrote |
Just wondering if this issue is still in the pipeline to implement? I'm still interested! :) |
Another possible stty issue: #14938 |
FYI, after the latest update, I ran a Jupyter Notebook on VSC and it started the kernel and ran cells with no problems! |
@karrtikr could this be closed? |
Yep, closing as |
Original issue https://github.com/microsoft/vscode-python/issues/8928
The experiment was temporarily disabled #9967 and old behavior was restored #9967 until we update to use the latest VSC API which allows us to hide terminal.
That API is now available, so this should be restored. This solves various issues like #12739 and some datascience issues like https://github.com/microsoft/vscode-python/issues/8823 where getting environment variables within the activated environment using process fails.
cc @DonJayamanne @greazer @rchiodo
The text was updated successfully, but these errors were encountered: