-
Notifications
You must be signed in to change notification settings - Fork 513
Formatting not working with 1.7.0 #1298
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
Comments
Those log entries are just from the extension - VSCode side. We need the logs from the language service - PSES side - to see what is going wrong in PSES. |
It's this again. 2018-04-28 07:41:40 [ERROR] - Method "InvokePowerShell" at line 445 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Analysis\AnalysisService.cs
1524897678-76060de6-59b9-4e70-9686-24a835ab003d1524897335539.zip |
From a regular PowerShell prompt can you If that works, try the same thing from the PSIC in VSCode. And if that works, execute this in PSIC:
PSScriptAnalyzer is a module that VSCode does not load by path. It relies on module auto-loading when a PSSA command is invoked. And the extension appends its I believe that strategy is flawed. We should be importing the module with a If this is indeed the issue, I would recommend removing versions of PSSA that don't have |
Ah, it looks like PSES does attempt to import the module explicitly.
However, this happens after several attempts to run |
This line is the issue. Previously it would use That's my bad, I remember specifically talking about this in review but must have missed that portion being removed. |
I'm going to let @rjmholt respond since we removed that logic on purpose. @SQLDBAWithABeard as a mitigation, if you install a newer version of PSScriptAnalyzer, your issue should go away. |
Yes, this is my fault. I changed the PSScriptAnalyzer import so it would honour the module path. Previously it searched all available modules and found the most recent one on the path and imported it. I've been hearing a lot of PowerShell users saying how impossible it is when they can't specify a lower version of something (mainly in PowerShell), and it seemed bad that we were second-guessing the import module logic. I think we should keep the behaviour the honours the module path, but we should do a minimum version check. We currently use a PowerShell module "API", but it's not a very good one and I think instead we should try actually invoking But, if this is actually trying to import the module at the exact path like @rkeithhill says, then it might not be what we think and may be trickier. Again though, the "API" we use, despite claiming to import a module, only puts it in a list of modules to import at some later point. I think we might solve this by invoking Does that seem reasonable? Or bad and broken? |
Makes sense to me, I've run into that and it's not fun.
That would work with how we currently configure the PSSA If it's possible to enforce a minimum version with |
Yeah, I was wondering about that. I'll look into whether doing this with the |
gmo PSScriptAnalyzer -ListAvailable | % Path gives C:\Users\mrrob\OneDrive\Documents\WindowsPowerShell\Modules\PSScriptAnalyzer\1.10.0\PSScriptAnalyzer.psd1 Importing from VSIC doesn't resolve the issue :-( But copying 1.16.1 into the PSMOdulePath and reloading does :-) Thankyou @tylerl0706 |
Just for context, PowerShell resolves an ipmo in order of PSModulePaths: if PSModulePath has:
and you In the extension, we add a path to the END of PSModulePath:
which contains a version of PSSA and Plaster. If you have a version of PSSA in one of the folders before that folder in your PSModulePath (and it looks like @SQLDBAWithABeard did! 😄), then we install that version of PSSA. @rjmholt did a great job explaining why we are honoring what ipmo does. |
@SQLDBAWithABeard Just to document, importing the module from within VSCode won't resolve the issue because PSScriptAnalyzer starts from a runspace pool when the extension starts up (which is precisely why using the PSScriptAnalyzer runs in its own sandbox essentially, so state changes in the editor won't affect it. It works by sending the text of the script into the sandbox over to it and spitting results back out. This is good because it means it doesn't depend on the state of the editor, so it can be parallelised. Then when you start the extension up (formally, when you start the EditorServices process, which the extension does), it tacks its own modules directory onto the end of the module path. Which is nice because it means you can override its internal module versions by just sticking your own module anywhere on your module path. And the intent is that eventually it should be possible to integrate other modules with the extension just by having them on the path. The problem was that despite going to the trouble of using the module path, we weren't honouring it. Except now we have the issue that an incompatible version of PSScriptAnalyzer on the module path can break us, so we need to address that by somehow specifying what our version constraints are at load time... |
I saw the same issue and did delete the PSScriptAnalyzer stored in: Can anyone explain, why it got stored in this location and not in |
@andikrueger it depends on whether you installed PSSciptAnalyzer with
if I were to do Install-Module PSScriptAnalyzer -Scope CurrentUser The module would end up in the first location (aka the current user scope) in my PSModulePath:
if I were to do Install-Module PSScriptAnalyzer The module would end up in the second location in my PSModulePath:
|
Is there a workaround for this? |
@andrewducker yes, You may need to do this in an elevated shell |
System Details
$PSVersionTable
:1.22.2
3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9
x64
ajor Minor Build Revision
1 7 0 0
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Name Value
PSVersion 5.1.16299.251
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.251
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
Formatting is not working I have tried this with Insiders and normal versions with a couple of different scripts with the same results
Attached Logs
You can see the log entries in the gif, it just says formatting finished but can upload more if you wish
The text was updated successfully, but these errors were encountered: