Open gauravjag opened 3 years ago
I can repro this and as a user that has transcription enabled by default on every execution of PowerShell this is a pain point for making use of Jupyter Notebooks going forward.
Using a simple example PowerShell code block like this when I have transcription enabled on pwsh via regkey
$processes = Get-process | Select Name,ID -Last 10
$processes
Results in this
when I then close vscode and re-open it with transcription disabled via reg key it then returns as expected
I'm not familiar with the Start-Transcript
implementation but I would venture a guess that it's interfering with .NET Interactive's console output redirection.
@daxian-dbw Any ideas?
It's not clear to me why it would interfere with the console output redirection. It looks like the powershell kernel doesn't write to console anymore after enabling transcription. I will need to attach a debugger to further investigate this.
This is because PowerShell automatically adds 'Out-Default -Transcript' to the end of pipeline when it's transcribing and invoked via API. When -Transcript
is specified, objects passed through are transcribed but are not passed ahead to the host.
The PowerShell sub-kernel actually already adds Out-Default
to pass output to host, however, we have to use Out-Default2
as the name due to a limitation in the native command processor. Since we are using Out-Default2
, PowerShell believes it doesn't have the Out-Default
command at the end, and thus adds Out-Default -Transcript
automatically, which prevents sending anything to the host and hence you don't see output when the transcription is turned on.
This needs to be fixed in PowerShell code, at here, to not just check for the Out-Default
name, but also check whether the ImplementingType
is typeof(OutDefaultCommand)
. I will open an issue in PowerShell repo and get it fixed there.
[Update] PowerShell issue opened: https://github.com/PowerShell/PowerShell/issues/15651. I will close this issue. The fix may be included in the next 7.1.x servicing release, but not guaranteed.
Thanks, @daxian-dbw!
I'm going to leave this open for tracking purposes until we pull the bug fix into .NET Interactive.
PowerShellTranscriptFailure.zip
Once Start-Transcript appears on a PowerShell notebook, any attempt to output to the notebook fails. See attached notebook for a repro.