Skip to content

"Unable to open 'File': resource is not available." when clicking on psscriptanalyzer problem #1732

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
andrewducker opened this issue Jan 28, 2019 · 11 comments
Assignees
Labels
Area-Script Analysis Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.

Comments

@andrewducker
Copy link

Issue Description

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.

image

Attached Logs

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.

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 6.1.7601
VSCode 1.30.2
PowerShell Extension Version 1.11.0

PowerShell Information

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

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
@andrewducker
Copy link
Author

Now replicated for all three people in my team.

@rkeithhill
Copy link
Contributor

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

@andrewducker
Copy link
Author

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.

@rkeithhill
Copy link
Contributor

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"

@andrewducker
Copy link
Author

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

@rkeithhill
Copy link
Contributor

That's how I observed the problem occurring on my machine. There may be other failure modes.

@brianmccarty
Copy link

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

@andyleejordan
Copy link
Member

@andrewducker sorry to follow up so late, but is this still an issue? Please let me know!

@andyleejordan andyleejordan added the Needs: Author Feedback Please give us the requested feedback! label May 23, 2023
@andrewducker
Copy link
Author

Sorry, not getting to work with PowerShell much at the moment, and so I don't have anything set up that I could test this with.

@ghost ghost added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Author Feedback Please give us the requested feedback! labels May 24, 2023
@andyleejordan
Copy link
Member

Ok! I'm going to close as resolved then. Thank you!

@andyleejordan andyleejordan added Resolution-Fixed Will close automatically. and removed Needs: Maintainer Attention Maintainer attention needed! labels Jun 7, 2023
@ghost ghost closed this as completed Jun 7, 2023
@ghost
Copy link

ghost commented Jun 7, 2023

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-Script Analysis Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.
Projects
None yet
Development

No branches or pull requests

5 participants