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
{{ message }}
Repository navigation
Python: Create Terminal Doesn't Use Activate.ps1 in Powershell #6928
Running the Python: Create Terminal command should properly activate my terminal using Activate.ps1
I expect to see this
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Loading personal and system profiles took 1881ms.
D:\MyProject [master ≡ +1 ~7 -0 !]> d:/MyProject/venv/Scripts/Activate.ps1
D:\MyProject [master ≡ +1 ~7 -0 !]>
Actual behaviour
The command activates my terminal with activate.bat
This is what I see
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Loading personal and system profiles took 1881ms.
D:\MyProject [master ≡ +1 ~7 -0 !]> d:/MyProject/venv/Scripts/activate.bat
D:\MyProject [master ≡ +1 ~7 -0 !]>
Steps to reproduce:
Run the Python: Create Terminal command.
Reacted by Philippe MacKay, Gabe R. , Arno Gobbin and Dan O'Sullivan
It affects Powershell Core 6 as well as Powershell. One possible workaround is to switch default shell to cmd, but I prefer the flexibility of Powershell.
The other option is to stay on version 2019.6.24221, which is not affected by this bug.
I created the environment with this line inside a batch script: py -3.7-64 -m venv --clear --copies ..\\envMyProject
By following your instructions, I have the following output. Seems like the core of the problem comes from the following: [Error: [ms-python.python]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ms-python.python
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: [object Object]. Shell identified as undefined
console.ts:134 [Extension Host] Error Python Extension: 2019-08-12 17:16:18: Unable to determine shell using VS Code API. [Error: [ms-python.python]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ms-python.python at a (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:472:367) at Object.t.checkProposedApiEnabled (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:473:343) at Object.get shell [as shell] (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:726:799) at p.get shell [as shell] (C:\Users\PhilMacKay\.vscode\extensions\ms-python.python-2019.8.29288\out\client\extension.js:75:305726) at u.identify (C:\Users\PhilMacKay\.vscode\extensions\ms-python.python-2019.8.29288\out\client\extension.js:75:445660) at p.identifyTerminalShell (C:\Users\PhilMacKay\.vscode\extensions\ms-python.python-2019.8.29288\out\client\extension.js:75:440845) at m.identifyTerminalShell (C:\Users\PhilMacKay\.vscode\extensions\ms-python.python-2019.8.29288\out\client\extension.js:75:437149) at f.ensureTerminal (C:\Users\PhilMacKay\.vscode\extensions\ms-python.python-2019.8.29288\out\client\extension.js:75:435275) at f.show (C:\Users\PhilMacKay\.vscode\extensions\ms-python.python-2019.8.29288\out\client\extension.js:75:435149) at l.onCreateTerminal (C:\Users\PhilMacKay\.vscode\extensions\ms-python.python-2019.8.29288\out\client\extension.js:75:898642) at l.module.exports.t.captureTelemetry.o.value (C:\Users\PhilMacKay\.vscode\extensions\ms-python.python-2019.8.29288\out\client\extension.js:1:8867) at f._executeContributedCommand (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:503:621) at f.$executeContributedCommand (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:504:6) at d._doInvokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:653:1006) at d._invokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:653:698) at d._receiveRequest (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:652:346) at d._receiveOneMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:651:141) at define.constructor._protocol.onMessage.e (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:649:400) at u.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:48:468) at a (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:177:627) at e (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:177:673) at u.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:48:468) at n.constructor.e.onMessage.e (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:758:621) at u.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:48:468) at a (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:177:627) at e (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:177:673) at u.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:48:468) at y._receiveMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:186:545) at define.constructor._socketDisposables.push._socketReader.onMessage.e (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:183:860) at u.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:48:468) at f.acceptChunk (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:180:393) at define.constructor._register._socket.onData.e (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:179:731) at Socket.t (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:188:22) at Socket.emit (events.js:182:13) at addChunk (_stream_readable.js:283:12) at readableAddChunk (_stream_readable.js:264:11) at Socket.Readable.push (_stream_readable.js:219:10) at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)]
t.log @ console.ts:134
$logExtensionHostMessage @ mainThreadConsole.ts:38
_doInvokeHandler @ rpcProtocol.ts:394
_invokeHandler @ rpcProtocol.ts:379
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:558
a @ ipc.net.ts:421
e @ ipc.net.ts:428
fire @ event.ts:558
_receiveMessage @ ipc.net.ts:715
S._socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:578
fire @ event.ts:558
acceptChunk @ ipc.net.ts:236
_register._socket.onData.e @ ipc.net.ts:197
t @ ipc.net.ts:28
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: [object Object]. Shell identified as undefined
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Shell path 'C:\Program Files\PowerShell\6\pwsh.exe'
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Shell path identified as shell 'powershellCore'
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Shell path from user settings 'C:\Program Files\PowerShell\6\pwsh.exe'
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: [object Object]. Shell identified as powershellCore
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Shell identified as 'powershellCore'
c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
t.addDisposableDomListener @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
t.bindMouse @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
t.open @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
e.open @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
_xtermReadyPromise.then @ terminalInstance.ts:548
_tickCallback @ internal/process/next_tick.js:68
c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
t.addDisposableDomListener @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
t.bindMouse @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
t.open @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
e.open @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
_xtermReadyPromise.then @ terminalInstance.ts:548
_tickCallback @ internal/process/next_tick.js:68
c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
t.addDisposableDomListener @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
t.bindMouse @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
t.open @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
e.open @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
_xtermReadyPromise.then @ terminalInstance.ts:548
_tickCallback @ internal/process/next_tick.js:68
c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
t.addDisposableDomListener @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
t.bindMouse @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
t.open @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
e.open @ c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
_xtermReadyPromise.then @ terminalInstance.ts:548
_tickCallback @ internal/process/next_tick.js:68
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Shell path 'Python'
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Shell path identified as shell 'other'
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Terminal name 'Python' identified as shell 'other'
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: [object Object]. Shell identified as other (Terminal name is Python)
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Shell identified as 'other'
console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Using default OS shell
2console.ts:134 [Extension Host] Info Python Extension: 2019-08-12 17:16:18: Cached data exists getEnvironmentVariables, c:\Sources\MyProject
Notice, however, that when using the command Terminal: Create New Integrated Terminal, the virtual environment is correctly activated using the .ps1 script.
Just want to add to this I have been having the same issue.
Perhaps the best way to fix this would be to call venv/Scripts/activate as opposed to activate.ps1 or activate.bat, as this file will be present irregardless of what terminal is being used to activate the venv, and always works (in my experience) I have looked at the source for this extension as I have considered changing this myself, but I do not know typescript, and cannot figure out how I would do this myself.
Extension version (available under the Extensions sidebar): 2019.8.30787
OS and version: Windows 10 Pro 10.0.18362 Build 18362
Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.2 32 bit
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
[Extension Host] Info Python Extension: 2019-08-20 13:30:23: [object Object]. Shell identified as undefined
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Shell path 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe'
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Shell path identified as shell 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Terminal shell path 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' identified as shell 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: [object Object]. Shell identified as powershell
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Shell identified as 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Shell path 'Python'
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Shell path identified as shell 'other'
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Terminal name 'Python' identified as shell 'other'
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: [object Object]. Shell identified as other (Terminal name is Python)
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Shell identified as 'other'
console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Using default OS shell
2console.ts:137 [Extension Host] Info Python Extension: 2019-08-20 13:30:23: Cached data exists getEnvironmentVariables, c:\Users\rick\Documents\Online authoring\webapp\models\entity.py
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\rick\Documents\Online authoring> "c:/Users/rick/Documents/Online authoring/venv/Scripts/activate.bat"
c:/Users/rick/Documents/Online authoring/venv/Scripts/activate.bat
PS C:\Users\rick\Documents\Online authoring>
Hello! I did some digging tonight with the code pulled from github.
The issue seems to be related to the shellDetector that works based on the name of the terminal. If it doesn't have a match, it returns the value "other", which is then considered a success on line 57 of the same file.
By changing the test condition from if (shell) { to if (shell && shell !== 'other') {, the detection is considered failed and the next detectors can be used. It leads to a correct detection of the shell type, therefore the correct "activate" script is used.
I don't know if the test condition in the identifyTerminalShell needs to be modified, or if it's the shell detector itself that should return undefined instead of the value "other"...
Anyways, I hope this helps! I would make a pull request but my modification actually breaks two unit tests:
Interpreters Known Paths
Ensure known list of paths are returned on non-windows
Ensure PATH variable and known list of paths are merged on non-windows
Activity
PhilMacKay commentedon Aug 12, 2019
Hi! I confirm I have the same issue, but with small differences in the environment:
Environment data
It affects Powershell Core 6 as well as Powershell. One possible workaround is to switch default shell to
cmd, but I prefer the flexibility of Powershell.The other option is to stay on version 2019.6.24221, which is not affected by this bug.
DonJayamanne commentedon Aug 12, 2019
Radwan Faci (@rafaci) Philippe MacKay (@PhilMacKay)
Help-> Toggle Developer Tools)ConsoletabClear Consoleicon on the top left)Python: Create TerminalConsoletabconsoleoutput windowThe information helps us identify the type of the shell being detected by the extension.
PhilMacKay commentedon Aug 12, 2019
Don Jayamanne (@DonJayamanne)
I created the environment with this line inside a batch script:
py -3.7-64 -m venv --clear --copies ..\\envMyProjectBy following your instructions, I have the following output. Seems like the core of the problem comes from the following:
[Error: [ms-python.python]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ms-python.pythonNotice, however, that when using the command
Terminal: Create New Integrated Terminal, the virtual environment is correctly activated using the.ps1script.rafaci commentedon Aug 15, 2019
Here's the output I get for version 2019.8.30787 (broken)
Here's the output I get with version 2019.6.24221 (working)
marsfan commentedon Aug 16, 2019
Just want to add to this I have been having the same issue.
Perhaps the best way to fix this would be to call venv/Scripts/activate as opposed to activate.ps1 or activate.bat, as this file will be present irregardless of what terminal is being used to activate the venv, and always works (in my experience) I have looked at the source for this extension as I have considered changing this myself, but I do not know typescript, and cannot figure out how I would do this myself.
DonJayamanne commentedon Aug 16, 2019
Philippe MacKay (@PhilMacKay) Please could you try upgrading your version of VS Code to the latest version (1.37)
PhilMacKay commentedon Aug 19, 2019
Gladly! Here is the log using
venvfor virtual environment"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe":Same thing but with PowerShell Core 6 (
"terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\\6\\pwsh.exe")silverches commentedon Aug 20, 2019
I seem to be having the same issue
Environment data
PhilMacKay commentedon Sep 3, 2019
Hello! I did some digging tonight with the code pulled from github.
The issue seems to be related to the
shellDetectorthat works based on the name of the terminal. If it doesn't have a match, it returns the value "other", which is then considered a success on line 57 of the same file.By changing the test condition from
if (shell) {toif (shell && shell !== 'other') {, the detection is considered failed and the next detectors can be used. It leads to a correct detection of the shell type, therefore the correct "activate" script is used.I don't know if the test condition in the
identifyTerminalShellneeds to be modified, or if it's the shell detector itself that should returnundefinedinstead of the value "other"...Anyways, I hope this helps! I would make a pull request but my modification actually breaks two unit tests:
Interpreters Known Paths
Ensure known list of paths are returned on non-windows
Ensure PATH variable and known list of paths are merged on non-windows
Thanks for the help!
1 remaining item
karrtikr commentedon Sep 18, 2019
validated