Skip to content
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

Error message "is a file type that cannot be debugged by the powershell debug" with capital file extension .PS1 #641

Closed
wellsluo opened this issue Apr 1, 2017 · 16 comments
Assignees
Labels
Milestone

Comments

@wellsluo
Copy link

wellsluo commented Apr 1, 2017

System Details

  • Operating system name and version: Windows 10
  • VS Code version: 1.10.2
  • PowerShell extension version: 0.11.0
  • Output from $PSVersionTable:
    Name Value

PSVersion 5.1.14393.953
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.953
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Copy / paste the below commands into the PowerShell Integrated Terminal, and paste the output here

code -v
$pseditor.EditorServicesVersion
code --list-extensions --show-versions
$PSVersionTable

code -v
1.10.2
8076a19fdcab7e1fc1707952d652f0bb6c6db331
PS D:> $pseditor.EditorServicesVersion

PS D:> code --list-extensions --show-versions

Adrien.VisualStudioDarkTheme@1.0.1
alefragnani.Bookmarks@0.12.0
emilast.LogFileHighlighter@1.1.1
emmanuelbeziat.vscode-great-icons@1.1.47
IBM.output-colorizer@0.1.0
ms-vscode.cpptools@0.10.5
ms-vscode.PowerShell@0.11.0
ms-vscode.wordcount@0.1.0
msazurermtools.azurerm-vscode-tools@0.3.4
robertohuertasm.vscode-icons@7.4.0
slevesque.vscode-hexdump@1.2.1

PS D:> $PSVersionTable

Name Value


PSVersion 5.1.14393.953
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.953
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Issue Description

When the file extension is capital, it reports error like:
"is a file type that cannot be debugged by the powershell debug"

Attached Logs

Follow the instructions in the README
about capturing and sending logs.

@wellsluo
Copy link
Author

wellsluo commented Apr 1, 2017

Add comments to commit: 47b4c5f

@rkeithhill rkeithhill self-assigned this Apr 1, 2017
@daviwil
Copy link
Contributor

daviwil commented Apr 1, 2017

Thanks Wei! We'll get that fixed.

@daviwil daviwil added Area-Debugging Issue-Bug A bug to squash. labels Apr 1, 2017
@daviwil daviwil added this to the 0.12.0 milestone Apr 1, 2017
rkeithhill added a commit that referenced this issue Apr 1, 2017
Was previously only allowing lower case ps1 and psm1.  I'm assuming that on *nix file systems, that PowerShell allows all variations of ps1,PS1,pS1,Ps1 as valid script extensions.

Fix #641
rkeithhill added a commit that referenced this issue Apr 2, 2017
* Fix detection of valid PS ext for debugging.

Was previously only allowing lower case ps1 and psm1.  I'm assuming that on *nix file systems, that PowerShell allows all variations of ps1,PS1,pS1,Ps1 as valid script extensions.

Fix #641

* Fix issue with debugging unsaved file.

* Use same term used in the command palette.

* Shorten error message based on juneb feedback.
@DrYSG
Copy link

DrYSG commented May 16, 2017

@rkeithhill Hey, I was having this issue with lowercase .ps1 and changed it to .PS1 and it works. VSCODE 1.12.2

@daviwil
Copy link
Contributor

daviwil commented May 16, 2017

@DrYSG You're still having this issue with PowerShell extension 1.0?

@DrYSG
Copy link

DrYSG commented May 16, 2017

WIndows 10

ame                           Value
----                           -----
PSVersion                      5.1.14393.1066
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.1066
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

image

@rkeithhill
Copy link
Contributor

What version of the PowerShell extension do you have?

image

@DrYSG
Copy link

DrYSG commented May 16, 2017

image

image

@rkeithhill
Copy link
Contributor

So you have 1.0.0 of this extension installed into VSCode? The original bug was the opposite of what you are reporting. PS1 did not work while ps1 did work. Can you provide some repro steps? Thanks.

@DrYSG
Copy link

DrYSG commented May 16, 2017

Yes, that is the funny thing. I am reporting the opposite. PS1 works and ps1 does not.

Steps

  1. Create a powershell script named foobar.ps1 put some commands in it.
  2. Use this launch.json shown below
  3. Run the the debugger the "Launch current File" script
    Make sure that the open tab is the PS1 file

Is there a newer version for the launch.json that 0.2.0 (I know I am using 2.0.0 for the tasks.json).?

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "PowerShell",
            "request": "launch",
            "name": "PowerShell Launch Current File",
            "script": "${file}",
            "args": [],
            "cwd": "${file}"
        },
        {
            "type": "PowerShell",
            "request": "launch",
            "name": "PowerShell Interactive Session",
            "cwd": "${workspaceRoot}"
        }
    ]
}

@rkeithhill
Copy link
Contributor

The version of launch.json should be 0.2.0.

@StingyJack
Copy link

If I start by opening a folder with with a .ps1. and try to debug that .ps1 I get the OP error. I can rename the file to .ps1 within VSC and then it debugs. If I rename it back to ,ps1 again, I can now debug it.

I looked through the commits tied to this, and the extension handling looks correct (not using locale, but I dont think that matters), so there is probably something wrong with the currentDocument.languageId thats evaluated.

Is there a way to dump out the current documents language id property without setting up a debug session?

@rkeithhill
Copy link
Contributor

@StingyJack Are you on the latest VSCode release? Also, what OS are you using?

VSCode should indicate the document's language in the lower right part of the status bar. In looking at this I noticed the following in the VSCode docs:

A language identifier is often (but not always) the lowercased programming language name. Note that casing matters for exact identifier matching ('Markdown' != 'markdown'). Unknown language files have the language identifier plaintext.

We've had this warning in our package.json file for a long time:

image

But that is just the package name so I guess the warning doesn't matter? This is where we activate based on the language:

  "activationEvents": [
    "onDebugResolve:powershell",
    "onLanguage:powershell",

In looking at the list of VSCode langauge identifiers, they have misspelled Powershell - it should be PowerShell but maybe that is just on the web page.

@StingyJack
Copy link

case sensitive language identifiers is a bug =D (seriously, whoever wrote that doc isnt thinking. These are human-used identifiers like someone's name and would be capitalized based on i18n sometimes, not machine understood data where casing may be important)

It does show PowerShell as the language.
image

I'm just not sure if it is setting that correctly in the code when its making the evaluation. Only a debug session will tell for sure.

@rkeithhill
Copy link
Contributor

This is hard for me to debug since I can't repro it. BTW I debug workspaces with .ps1 files in them all the time. Maybe you could tell me how you are debugging i.e. what is the debug configuration you are using.

Also, this doesn't quite parse for me:

If I start by opening a folder with with a .ps1. and try to debug that .ps1 I get the OP error. I can rename the file to .ps1 within VSC and then it debugs. If I rename it back to ,ps1 again, I can now debug it.

You say you rename the file from a .ps1 to .ps1 in VSC. What am I missing here because it looks like you are not making any change to the extension. And when you rename it back to ,ps1 I assume that's a typo because ,ps1 does not specify a file extension.

@StingyJack
Copy link

StingyJack commented Apr 2, 2018

it should say

If I start by opening a folder with with a powershell script ending in .ps1. and try to debug that .ps1 I get the OP error. I can rename the file to .PS1 within VSC and then it debugs. If I rename it back to .ps1 again, I can now debug it.

Its the uppercasing of the extension that fixes it for the file, for the session. This is more or less fresh install, as I don't use VSC often at all. I update it whenever it asks.

@rkeithhill
Copy link
Contributor

Thanks for clarifying. That is pretty weird though. Hmm....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants