Vscode-powershell: exiftool.exe hangs on Run Selection (F8)

Created on 15 Mar 2020  路  6Comments  路  Source: PowerShell/vscode-powershell

System Details


System Details Output

### VSCode version: 1.43.0 78a4c91400152c0f27ba4d363eb56d2835f9903a x64

### VSCode extensions:       
[email protected]


### PSES version: 2.0.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

When using the Call Operator (&) and using F8 (Run Selection) to run Exiftool (the stand-alone Windows executable HERE), the terminal hangs as if it's waiting for something. This means it's then necessary to click inside the terminal window, and then either press the 'ESC' key (which will then allow Exiftool to run), or press 'CTRL + C' (which will abort the operation).

When using the 'Terminal' menu items in VSCode, Exiftool runs OK without hanging.

To summarise:

Exiftool runs OK when using the following methods.
Menu > Terminal > Run Active File
Menu > Terminal > Run Selected Text

Terminal hangs when using the following methods.
Menu > Run > Start Debugging (F5)
Right-clicking selected text in Editor > Run Selection (F8)

Example code (no paramenters set and assuming the Exiftool executable is saved to desktop):
& "$env:UserProfile\Desktop\exiftool.exe"

Expected Behaviour

The exiftool executable should run without hanging, like it does when using the 'Terminal' menu items.

Screenshot:
Screenshot B

Actual Behaviour

The terminal hangs without executing Exiftool, as if waiting for something, until the user intervenes by pressing either 'ESC' or 'CTRL + C' in the Terminal window.

Screenshot:
Screenshot A

Area-UI Issue-Bug

All 6 comments

It would be really helpful if you could also attach the logs--instructions for how to do that are here

Log files attached:

Logs.zip

VSCode settings:

settings.zip

+1 Not sure why this is still marked needs repro, but here's another example.

$focalLength = &"$env:USERPROFILETools\Images\exiftool.exe" -FocalLength -b "$path\$fileName.MP4"

This line works fine when copy/pasted into Visual Studio Code's PowerShell terminal, when run in PowerShell 7 directly, and when run in PowerShell ISE.

Calls to other tools, such as

$resolution = &"C:\Windows\System32\nslookup.exe" "microsoft.com"

are more successful.

### VSCode version: 1.43.2 0ba0ca52957102ca3527cf479571617f0de6ed50 x64
### VSCode extensions: [email protected]
### PSES version: 2.0.0.0
### PowerShell version:
Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

I just managed to look into this, and got a repro on my machine specifically with exiftool.exe. The call operator isn't an influence here, since running the tool directly has the same effect.

I suspected this might be an issue with the integrated terminal interacting with more, but more .\longfile.txt and help Get-Help -Full both work as expected.

Given the specificity of this bug to a particular executable, it's unlikely we'll have time to look into this ourselves.

Since this works in the integrated console today, one workaround is to use VSCode's own "run in terminal" functionality, rather than the extension's (which is $PSScriptRoot aware). To do this with F8, set this keybinding configuration:

{
 "key": "f8",
 "command": "workbench.action.terminal.runSelectedText"
 }

As already mentioned, another workaround is interacting with the console after running the selection, like by pressing Esc or Enter.

This is an oddly specific issue that I am hitting right now, so... bump!

I've tried various things and I just cannot get this process to terminate cleanly.

Edit: I just realized that this is only when running in VS Code. The work around is fine for me at least, as it's only in debugging situations.

I just checked with VS Code 1.52.1 and PowerShell 7.1 and, while two orders of magnitude slower than running in PowerShell 7 directly (or the old ISE), the VS Code console instance of pwsh.exe did see exiftool exit and get the return variable from the call populated. Unfortunately this only worked once, immediately after the update of VS Code and PowerShell, and all subsequent attempts have hung indefinitely as previously reported.

I wonder if this might perhaps be an indication VS Code is hooking into exiftool's stdout or stderr streams even though the interactions between pwsh.exe and exiftool.exe would, in principle, presumably be encapsulated to those two processed and therefore independent of code.exe. However, I can't think of an explanation for why calling exiftool would only work once after an update.

Was this page helpful?
0 / 5 - 0 ratings