Vscode-powershell: Any prompt for input on Linux times out.

Created on 30 Apr 2019  路  4Comments  路  Source: PowerShell/vscode-powershell

System Details



System Details Output

### VSCode version: 1.33.1 51b0b28134d51361cf996d2f0a1c698247aeabd8 x64

### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version: 2.0.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      6.2.0
PSEdition                      Core
GitCommitId                    6.2.0
OS                             Linux 4.18.16-300.fc29.x86_64 #1 SMP Sat Oct 20 23:24:08 UTC 2018
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

When running commands on Linux which are prefixed with sudo, the Powershell Integrated Console will timeout the prompt before there is chance to enter characters.

Expected Behaviour

The prompt should wait (indefinitely?) for the user to enter characters. This works as expected in any other terminal (even if I create an VSCode terminal which starts bash, then enter pwsh).

Actual Behaviour

As you can see below (the same happens for any command prefixed with sudo). If i don't type any characters, this times out in just over a second.

(base) PS> Measure-Command {read -s pass }


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 1
Milliseconds      : 28
Ticks             : 10286362
TotalDays         : 1.19055115740741E-05
TotalHours        : 0.000285732277777778
TotalMinutes      : 0.0171439366666667
TotalSeconds      : 1.0286362
TotalMilliseconds : 1028.6362

How to Resolve

I was able to diagnose this myself in the end, but wanted to make a note for anyone else who may experience this.

I share my settings.json between Windows and Linux, and I had the following setting turned on to use PSReadline (for Windows):

    "powershell.developer.featureFlags": [
        "PSReadLine"
    ],

Disabling this setting and reloading seems to completely resolve the issue.

Area-PSReadLine Issue-Bug Preview Extension

Most helpful comment

This is fixed if you use the preview version of PowerShell 7!

All 4 comments

Since it looks like PSReadLine is enabled by default now, I suppose it's unlikely anyone would end up in this situation, unless they have an older settings file they end up moving to a Linux machine.

It could still be nice to protect against this if anyone does end up in this scenario. It had been frustrating me for quite some time before I got around to diagnosing.

Looks like it could be fixed by filtering the featureFlags out based on the OS here:
https://github.com/PowerShell/vscode-powershell/blob/f9e13c62c4a8cc42e23842eaa15bd4987f7f8772/src/process.ts#L52-L56

Hi @jclay, thanks for opening an issue.

This is a known issue that we've been working toward fixing. I thought there would be an existing issue, but can't find one.

The problem occurs because PSReadLine must cancel the prompt in order to process messages from the extension. On Windows there is a solution to this problem, but on *nix the API does not exist. Essentially it's a difficult issue with no easy fix.

We chose to allow the usage of PSReadLine in nix, but not have it turned on by default, as opposed to on Windows where PSReadLine *is turned on by default. This is so it's still possible to opt-in to PSReadLine, but must be explicitly configured.

As I say, we're working toward a solution.

This is fixed if you use the preview version of PowerShell 7!

We will be waiting to release the "preview" extension as "stable" until after 7 GA so I'm going to close this as there's no work on the extension side needed. The recommendation is to use PowerShell 7. 6.2 will be EOL 6 months after 7's release anyway.

For 6.2, we fallback to the legacy readline so at least the experience in the extension isn't broken, just not as nice as PowerShell 7's.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timoline picture timoline  路  3Comments

borisimple picture borisimple  路  3Comments

daviwil picture daviwil  路  4Comments

AWahlqvist picture AWahlqvist  路  3Comments

daviwil picture daviwil  路  3Comments