PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

Feature Request: improve "cannot run a document" message

Open aelij opened this issue 4 years ago • 10 comments

Summary of the new feature/enhancement

I had to go look at the source code to understand what "cannot run a document" actually meant. Please consider rewording this. Perhaps - "cannot run a non-executable".

Note that are two messages with this wording - CantActivateDocumentInPipeline and CantActivateDocumentInPowerShellCore.

https://github.com/PowerShell/PowerShell/blob/c909541b7797b60462188a4abe9592a8763c1fbb/src/System.Management.Automation/engine/NativeCommandProcessor.cs#L1133-L1146

aelij avatar Jan 07 '21 08:01 aelij

/cc @sdwheeler @joeyaiello

iSazonov avatar Jan 07 '21 12:01 iSazonov

@aelij Please add links to source code to help reviewers.

iSazonov avatar Jan 07 '21 12:01 iSazonov

@iSazonov Added

aelij avatar Jan 07 '21 12:01 aelij

@aelij Thanks! Could you please add links to CantActivateDocumentInPipeline and CantActivateDocumentInPowerShellCore resource string too?

iSazonov avatar Jan 07 '21 12:01 iSazonov

PowerShell/src/System.Management.Automation/resources/ParserStrings.resx

Line 592:

  <data name="CantActivateDocumentInPipeline" xml:space="preserve">
    <value>Cannot run a document in the middle of a pipeline: {0}.</value>
  </data>

Suggested text: "Cannot invoke a document in the middle of a pipeline: {0}"

Line 1356:

  <data name="CantActivateDocumentInPowerShellCore" xml:space="preserve">
    <value>Cannot run a document in PowerShell: {0}.</value>
  </data>

Suggested text: "This platform does not support file handlers for document invocation: {0}"

sdwheeler avatar Jan 07 '21 18:01 sdwheeler

@sdwheeler I find word "document" a bit confusing (and somewhat Windows-y :). Shells have files and executables. Even the PS error when it can't find a command doesn't use this word:

The term 'foo' is not recognized as a name of a cmdlet, function, script file, or executable program.

aelij avatar Jan 12 '21 14:01 aelij

I defer to the product team for better wording. But, as I understand it, document invocation is a Windows specific feature and that is what this error is about.

sdwheeler avatar Jan 12 '21 15:01 sdwheeler

It's basically using ProcessStartInfo.UseShellExecute which is supported on multiple platforms.

aelij avatar Jan 12 '21 15:01 aelij

Can this be bumped? I had no idea what this meant and I'm fluent in both Linux and Windows. If the team would like to stand by the "document" word, please append a helpful message that lets us know we have to make it executable.

potatoqualitee avatar Oct 22 '22 15:10 potatoqualitee

This is a beautiful and helpful error message.

Line |
   3 |  Install-Package Microsoft.PowerShell.SDK -RequiredVersion 7.2.7 -Skip …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Sudo rights are required to install packages in
     | '/usr/local/share/PackageManagement/NuGet/Packages'. Try again
     | by launching powershell with sudo, or install in
     | '/home/runner/.local/share/PackageManagement/NuGet/Packages'
     | by adding "-Scope CurrentUser" to your command.

potatoqualitee avatar Oct 22 '22 17:10 potatoqualitee

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.