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

Terminal process terminated with exit code 4294901760 #174658

Closed
qaqz111 opened this issue Feb 17, 2023 · 6 comments
Closed

Terminal process terminated with exit code 4294901760 #174658

qaqz111 opened this issue Feb 17, 2023 · 6 comments
Assignees
Labels
extensions Issues concerning extensions

Comments

@qaqz111
Copy link

qaqz111 commented Feb 17, 2023

I searched issues list and found several similar issues reported but nothing has been settled.

Here's my steps to reproduce this problem:

  1. prepare a fresh installed VM with Win10x64, newest VC redistributable libs installed. (maybe not necessary)
  2. download and unzip VSCode-win32-x64-1.75.1.zip to C:\VSCode
  3. make dir C:\VSCode\data
  4. download and install python using python-3.11.2-amd64.exe from python.org
  5. run VSCode, install extension Python by microsoft and Python Environment Manager by Don Jayamanne
  6. open Python pane by Python Environment Manager, click Refresh Environments button which was on top-right of the pane, the python installed should be found and put under Global node in the pane
  7. hover the mouse cursor on node Global -> Python (3.11.2) C:\XXXX...., the Open in Terminal and Set as active workspace interpreter buttons should appear on the right most of the node
  8. click Open in Terminal button, a terminal pane should appear at bottom of VSCode, giving an output message which saying Internal Windows PowerShell error. Loading managed Windows PowerShell failed with error 8009001d., then the terminal process terminated and terminal pane was closed, a notification banner popped up at right-bottom of VSCode saying The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" terminated with exit code: 4294901760.

I monitored the powershell.exe process's start commandline using ProcessMonitor (from sysinternals) and found the commandline is:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "try { . \"C:\VSCode\VSCode-v1.75.1\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1\" } catch {}"

This commandline works well in a cmd console but can not run in a powershell console and the pwsh shell report an error:

String missing terminator: ".
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

This is because powershell can not escape \" to " but should be [ `" ] in the commandline.
I don't know if this is the cause of the error, and also I don't know if this error is caused by the Python Environment Manager extension.

@qaqz111
Copy link
Author

qaqz111 commented Feb 17, 2023

Additional message maybe of help I found:

  1. Error code 0x8009001D / NTE_PROVIDER_DLL_FAIL, description: Provider DLL failed to initialize correctly.
    https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/705fb797-2175-4a90-b5a3-3918024b10b8

  1. Looks like another error which return the same error code 8009001d was settled by newer version of PowerShell:
    Start-Process fails to launch new powershell.exe instance with -UseNewEnvironment switch PowerShell/PowerShell#3545
    Here's more info maybe of help:
    I found that the Open in Terminal works fine with venv.
    These are the info ProcessMonitor captured:

For non venv:
For non venv

Parent PID:	6288
Command line:	C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "try { . \"c:\VSCode\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1\" } catch {}"
Current directory:	C:\Users\R9K_VM01\
Environment:	
	VSCODE_INJECTION=1

For venv:
For venv

Parent PID:	6288
Command line:	C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "try { . \"c:\VSCode\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1\" } catch {}"
Current directory:	C:\Users\R9K_VM01\
Environment:	
	ALLUSERSPROFILE=C:\ProgramData
	APPDATA=C:\Users\R9K_VM01\AppData\Roaming
	CHROME_CRASHPAD_PIPE_NAME=\\.\pipe\LOCAL\crashpad_5596_HUFBNCAARMEUMIOZ
	CommonProgramFiles=C:\Program Files\Common Files
	CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
	CommonProgramW6432=C:\Program Files\Common Files
	COMPUTERNAME=VM01-WIN10X64
	ComSpec=C:\Windows\system32\cmd.exe
	DriverData=C:\Windows\System32\Drivers\DriverData
	HOMEDRIVE=C:
	HOMEPATH=\Users\R9K_VM01
	LOCALAPPDATA=C:\Users\R9K_VM01\AppData\Local
	LOGONSERVER=\\VM01-WIN10X64
	NUMBER_OF_PROCESSORS=4
	OneDrive=C:\Users\R9K_VM01\OneDrive
	ORIGINAL_XDG_CURRENT_DESKTOP=undefined
	OS=Windows_NT
	Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\R9K_VM01\AppData\Local\Microsoft\WindowsApps
	PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
	PROCESSOR_ARCHITECTURE=AMD64
	PROCESSOR_IDENTIFIER=AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD
	PROCESSOR_LEVEL=25
	PROCESSOR_REVISION=5000
	ProgramData=C:\ProgramData
	ProgramFiles=C:\Program Files
	ProgramFiles(x86)=C:\Program Files (x86)
	ProgramW6432=C:\Program Files
	PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
	PUBLIC=C:\Users\Public
	SystemDrive=C:
	SystemRoot=C:\Windows
	TEMP=C:\Users\R9K_VM01\AppData\Local\Temp
	TMP=C:\Users\R9K_VM01\AppData\Local\Temp
	USERDOMAIN=VM01-WIN10X64
	USERDOMAIN_ROAMINGPROFILE=VM01-WIN10X64
	USERNAME=R9K_VM01
	USERPROFILE=C:\Users\R9K_VM01
	VSCODE_PORTABLE=C:\VSCode\data
	windir=C:\Windows
	TERM_PROGRAM=vscode
	TERM_PROGRAM_VERSION=1.75.1
	LANG=en_US.UTF-8
	COLORTERM=truecolor
	VSCODE_INJECTION=1

If you'd like to reproduce this, follow these steps:

  • run python -m venv C:\dir1\env0
  • run the .cmd of following code:
    @echo off
    if "%~1" equ "" goto:help
    
    pushd %~dp0
    if "%~2" neq "" (
        SET VNAM=%~1
        SET VDIR=%~f2
    ) else (
        SET VNAM=%~nx1
        SET VDIR=%~f1
    )
    
    SET PYEXE=%VDIR%\Scripts\python.exe
    if exist "%PYEXE%" (
        for /F "usebackq tokens=2,3 delims=. " %%i in (`"%PYEXE%" -V`) do (SET PYVER=%%i.%%j)
    ) else (
        echo "%PYEXE%" not found.
        goto:eof
    )
    
    reg add "HKCU\SOFTWARE\Python\VisualStudio\%VNAM%" /v "SysArchitecture"         /d "64bit"      /f
    reg add "HKCU\SOFTWARE\Python\VisualStudio\%VNAM%" /v "SysVersion"              /d "%PYVER%"    /f
    reg add "HKCU\SOFTWARE\Python\VisualStudio\%VNAM%" /v "PathEnvironmentVariable" /d "PYTHONPATH" /f
    reg add "HKCU\SOFTWARE\Python\VisualStudio\%VNAM%" /v "DisplayName"             /d "%VNAM%"     /f
    
    reg add "HKCU\SOFTWARE\Python\VisualStudio\%VNAM%\InstallPath" /ve /d "%VDIR%" /f
    reg add "HKCU\SOFTWARE\Python\VisualStudio\%VNAM%\InstallPath" /v "WindowedExecutablePath" /d "%VDIR%\Scripts\pythonw.exe" /f
    reg add "HKCU\SOFTWARE\Python\VisualStudio\%VNAM%\InstallPath" /v "ExecutablePath"         /d "%VDIR%\Scripts\python.exe"  /f
    
    goto:eof
    
    
    
    :help
    echo Usage:
    echo   ImptVenv.cmd [^<venv name^>] ^<venv dir^>
    echo     Note: ^<venv name^> and ^<venv dir^> should be quoted if necessary.
    pause
    
  • restart VSCode or reload Python Environment Manager extension and click Refresh Environments button to get the venv showing up on Python pane
  • click Open in Terminal button of venv node

  1. I tried change \" to [ `" ] in the commandline, it works well both in cmd and powershell console.

  1. The commandline generation is not done by Python Environment Manager extension, I can not found "noexit" or "try { ." in its source.

@meganrogge
Copy link
Contributor

Is there a reason you are using windows powershell?

Can you try to reproduce with an updated powershell version?

@meganrogge meganrogge added the info-needed Issue requires more information from poster label Feb 17, 2023
@qaqz111
Copy link
Author

qaqz111 commented Feb 18, 2023

The powershell I used is come with win10 installed, basically I do not use it at all in daily work, so there's no reason for me to install an updated version of powershell.

For this issue, I installed powershell-v7.3.2-x64.msi from this page: https://github.com/PowerShell/PowerShell/releases/tag/v7.3.2 in the VM, put the pwsh7 dir before the old one which comes with win10 in PATH env var. Good news is no 8009001d came out any more and terminal pane got works, but appears another issue that I do not know whether it is caused by pwsh7 or the Python Environment Manager extension.

In the Python pane of Python Environment Manager extension, Open in Terminal button works well for venvs, but the global non venv's Open in Terminal button will launch the terminal with the environment of current interpeter which was selected through F1->Python: Select Interpreter and displayed at right side of VSCode status bar.

See the screenshots:
x1
x2
xg
x11
x22

I found this issue was reported at Python Environment Manager extension project 1 more year ago, but still got no response for now.
Global environment not activating on Windows #7

@qaqz111
Copy link
Author

qaqz111 commented Feb 18, 2023

Unfortunately by correcting the commandline string VSCode generated did not fix the problem according to my tests.
I modified the local js file of VSCode installation on VM to generate correct commandline string, which was confirmed through ProcessMonitor, but with Windows PowerShell v5.1 the error 8009001d is still there.

So, is there any way to make VSCode terminal work fine with Windows PowerShell v5.1? Will there be a bugfix?

I'm really not sure whether installing pwsh7 will break the current development environment on some of our machines.

@meganrogge meganrogge removed the info-needed Issue requires more information from poster label Feb 21, 2023
@karthiknadig
Copy link
Member

@DonJayamanne
Copy link
Contributor

Closing this issue in favour of the extension bug DonJayamanne/vscode-python-manager#54

@github-actions github-actions bot locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions Issues concerning extensions
Projects
None yet
Development

No branches or pull requests

4 participants