Skip to content

exiftool.exe hangs on Run Selection (F8) #2559

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

Closed
DesertBear opened this issue Mar 15, 2020 · 9 comments
Closed

exiftool.exe hangs on Run Selection (F8) #2559

DesertBear opened this issue Mar 15, 2020 · 9 comments
Labels
Area-Extension Terminal Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.

Comments

@DesertBear
Copy link

System Details

System Details Output

### VSCode version: 1.43.0 78a4c91400152c0f27ba4d363eb56d2835f9903a x64

### VSCode extensions:       
ms-vscode.powershell@2020.3.0


### 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

@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 15, 2020
@SydneyhSmith
Copy link
Collaborator

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

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Mar 17, 2020
@DesertBear
Copy link
Author

DesertBear commented Mar 27, 2020

Log files attached:

Logs.zip

VSCode settings:

settings.zip

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 27, 2020
@SydneyhSmith SydneyhSmith added Issue-Bug A bug to squash. and removed Needs: Maintainer Attention Maintainer attention needed! labels Mar 31, 2020
@twest820
Copy link

twest820 commented Apr 11, 2020

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

$focalLength = &"$env:USERPROFILE\Tools\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: ms-vscode.powershell@2020.3.0
### 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

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 11, 2020
@SydneyhSmith SydneyhSmith added Area-UI and removed Needs-Repro-Info Needs: Maintainer Attention Maintainer attention needed! labels Apr 14, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Apr 14, 2020

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.

@rjmholt rjmholt changed the title PowerShell Hangs In VSCode When Using Call Operator (&) And Using F8 To Run Selection exiftool.exe hangs on Run Selection (F8) Apr 14, 2020
@JakeShirley
Copy link

JakeShirley commented Jan 4, 2021

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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jan 4, 2021
@twest820
Copy link

twest820 commented Jan 9, 2021

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.

@andyleejordan
Copy link
Member

@DesertBear Hi there, we just released v2022.4.0-preview! Could you please try PowerShell Preview for VS Code and verify this is fixed?

@andyleejordan andyleejordan added the Needs: Fix Verification Please verify the fix for us! label Apr 12, 2022
@andyleejordan
Copy link
Member

This was verified resolved in #3225 (comment)

@andyleejordan andyleejordan added Resolution-Fixed Will close automatically. and removed Needs: Fix Verification Please verify the fix for us! labels Apr 13, 2022
@andyleejordan andyleejordan moved this from In Progress to Done in Sea Biscuit Apr 13, 2022
@ghost ghost closed this as completed Apr 13, 2022
@ghost
Copy link

ghost commented Apr 13, 2022

This issue has been marked as fixed. It has been automatically closed for housekeeping purposes.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Extension Terminal Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.
Projects
No open projects
Status: Done
Development

No branches or pull requests

6 participants