When I click on a warning/error/info in the "Problems" tab, it then fails to open the file (which is, by the way, already open) and gives the error
Unable to open 'File.ps1': resource is not available.
This happens with both modules and scripts.
It doesn't happen every single time, but more than 50% of the time.

I turned logging up to Diagnostic. There was nothing coming up for this error. There were message in the analysis file for the file being opened/analysed/closed, but no errors.
| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 6.1.7601 |
| VSCode | 1.30.2|
| PowerShell Extension Version | 1.11.0 |
|Name|Value|
|---|---|
|PSVersion|5.1.14409.1018|
|PSEdition|Desktop|
|PSCompatibleVersions|1.0 2.0 3.0 4.0 5.0 5.1.14409.1018|
|BuildVersion|10.0.14409.1018|
|CLRVersion|4.0.30319.42000|
|WSManStackVersion|3.0|
|PSRemotingProtocolVersion|2.3|
|SerializationVersion|1.1.0.1|
Visual Studio Code Extensions(Click to Expand)
|Extension|Author|Version|
|---|---|---|
|gitlens|eamodio|9.4.1|
|json-tools|eriklynd|1.0.2|
|PowerShell|ms-vscode|1.11.0|
|printcode|nobuhito|3.0.0|
|qub-xml-vscode|qub|1.2.8|
|XMLLanguageSupport|IBM|0.0.1|
|zenburn|ryanolsonx|1.0.1|;
Now replicated for all three people in my team.
I believe what you are seeing is an issue we've already seen. It should be fixed in the next update. Still, could you upload your log files here so we can double check the root cause of what you're seeing? https://github.com/PowerShell/vscode-powershell/blob/master/docs/troubleshooting.md#logs
1548754604-8a65a9c9-d1e1-4d68-b361-d2c171bc13631548754580034.zip
I set the log level, then restarted VSCode (to get clean logs from startup), then opened a module, which triggered the extension to load. Once it had loaded (took several seconds) I then clicked on a few issues, but that all worked fine. I closed the file and opened it again, and it still worked fine, so I opened a different file, and that had the issue.
Yep, you are running into the known issue. When the extension publishes diagnostics for a file that you have opened explicitly, the link should work because it is returned to VSCode in the correct URI format e.g.:
"uri": "file:///c%3A/sebuild/tools/scripts/Modules/CVSVersionControl/CVSVersionControl.psm1"
However, if the extension itself opens the file and analyzes it (say it was dot-sourced or analyzed via the code lens provider) then it returns a file URI that is not properly encoded for VSCode:
"uri": "c:\\sebuild\\tools\\scripts\\Modules\\CVSConfig\\CVSConfig.psm1"
Interesting. Because in the above case I opened the file through VS Code, which them made the Problems list pop up, and then I clicked on an item in the Problems list.
Which you say should have worked...
That's how I observed the problem occurring on my machine. There may be other failure modes.
Having the same issue: The first time it worked, the second failed with the same uri pattern you showed.
PowerShell Editor Services Host v2.0.0.0 starting (PID 30052
Host application details:
Name: Visual Studio Code Host
Version: 2.0.0
ProfileId: Microsoft.VSCode
Arch: X64
Operating system details:
Version: Microsoft Windows 10.0.17763
Arch: X64
Build information:
Version: <development-build>
Origin: <development>
Date: 2019-01-23T18:25:10
Version: 1.31.0-insider (system setup)
Commit: b313db6c58f8c02181a33cd3b5b4b17c64a5b85d
Date: 2019-02-05T10:16:27.989Z
Electron: 3.1.2
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17763
md5-a217c4c372f5782ec09b2cf4b61b375c
2019-02-05 10:33:58.470 [VERBOSE] tid:17 in 'ReadMessageAsync' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
Received Event 'textDocument/didClose'
{
"jsonrpc": "2.0",
"method": "textDocument/didClose",
"params": {
"textDocument": {
"uri": "file:///c%3A/Code/dev.azure.com/cpi365/CPIITGlue/src/scripts/Scripts/MismatchedO365toITGlue.ps1"
}
}
}
2019-02-05 10:33:58.470 [VERBOSE] tid:17 in 'ResolveFilePath' C:\PowerShellEditorServices\src\PowerShellEditorServices\Workspace\Workspace.cs: line 466
Resolved path: c:\Code\dev.azure.com\cpi365\CPIITGlue\src\scripts\Scripts\MismatchedO365toITGlue.ps1
md5-a217c4c372f5782ec09b2cf4b61b375c
2019-02-05 10:33:58.470 [VERBOSE] tid:17 in 'WriteMessageAsync' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
Writing Event 'textDocument/publishDiagnostics'
{
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
"uri": "c:\\Code\\dev.azure.com\\cpi365\\CPIITGlue\\src\\scripts\\Scripts\\MismatchedO365toITGlue.ps1",
"diagnostics": []
}
}
2019-02-05 10:33:58.471 [VERBOSE] tid:17 in 'HandleDidCloseTextDocumentNotificationAsync' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\Server\LanguageServer.cs: line 616
Finished closing document.
Most helpful comment
Yep, you are running into the known issue. When the extension publishes diagnostics for a file that you have opened explicitly, the link should work because it is returned to VSCode in the correct URI format e.g.:
However, if the extension itself opens the file and analyzes it (say it was dot-sourced or analyzed via the code lens provider) then it returns a file URI that is not properly encoded for VSCode: