Closed sympmarc closed 4 years ago
Hi, I have exactly the same error as described above. Also a re-installation of "ms-vscode.PowerShell" wasn't successfull.
Message which will be displayed:
You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?
Command which will be executed if I click on "Yes":
powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'
Message which appears after the command was successfully executed:
PackageManagement updated, If you already had PackageManagement loaded in your session, please restart the PowerShell extension.
Directly afterwards the initial message appears again. This only happens twice to me.
### VSCode version:
Version: 1.47.2 (user setup)
Commit: 17299e413d5590b14ab0340ea477cdd86ff13daf
### PowerShell version:
Name Value
---- -----
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
### VSCode extensions:
bencoleman.armview
ckolkman.vscode-postgres
donjayamanne.githistory
eamodio.gitlens
hashicorp.terraform
jmrog.vscode-nuget-package-manager
ms-dotnettools.vscode-dotnet-runtime
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode.powershell
ms-vsts.team
msazurermtools.azurerm-vscode-tools
I have been getting the same issue for about a month issue. When I run the update requested I get an error:
You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?
PS E:\todd\Repos\Evolve-iMS\UNIT001_Apps> powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber' WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2/'. PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PackageManagement'. Try Get-PSRepository to see all available registered module repositories. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.0\PSModule.psm1:2057 char:21 ... $null = PackageManagement\Install-Package @PSBoundParameters
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage PS E:\todd\Repos\Evolve-iMS\UNIT001\_Apps>get-psrepository WARNING: MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «» WARNING: Unable to download the list of available providers. Check your internet connection. Name InstallationPolicy SourceLocation ---- ------------------ -------------- PSGallery Untrusted https://www.powershellgallery.com/api/v2/
Name | Version |
---|---|
Operating System | Windows_NT x64 10.0.14393 |
VSCode | 1.47.3 |
PowerShell Extension Version | 2020.6.0 |
Name | Value |
---|---|
PSVersion | 5.1.14393.3471 |
PSEdition | Desktop |
PSCompatibleVersions | 1.0 2.0 3.0 4.0 5.0 5.1.14393.3471 |
BuildVersion | 10.0.14393.3471 |
CLRVersion | 4.0.30319.42000 |
WSManStackVersion | 3.0 |
PSRemotingProtocolVersion | 2.3 |
SerializationVersion | 1.1.0.1 |
What is the output of gmo PackageManagement -ListAvailable
in the integrated console?
Before reinstalling PackageManagement:
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Command which runs:
powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'
After reinstalling PackageManagement:
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Before and after look the same to me...
@sympmarc does any error output appear in the integrated console?
No error at all. Just the prompt to reinstall PackageManager.
Since I posted the issue, I think I've figured out the pattern. The prompt comes up each time I open a new project folder, no matter how many other projects folders I have open in other VS Code windows. The prompt comes up right as the terminal window is revving up.
From that point forward in the project folder session, everything is fine.
If it's helpful, the prompt in the PowerShell Integrated Console is this:
=====> PowerShell Integrated Console v2020.6.0 <=====
PS D:\code\[...]>
If I garbage can the terminal window for any reason, I'm prompted again.
Here are the logs from one PS terminal session. I can broaden out if that is useful.
1595969526-8689461e-d76d-4354-9e2a-0f05974d7ce41595969454260.zip
Strangely, there doesn't seem to be any report of failure:
2020-07-28 16:52:16.270 -04:00 [VRB] Attempting to execute command(s):
powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'
Out-Default
It doesn't really feel like a failure, per se. It's more like the session doesn't see the installed version of PackageManager and thinks it needs a new install.
Here's a log with the reinstallation included. 1595970085-39394155-83d7-4431-b0d9-d0f1a64238f21595970040956.zip
Thanks @sympmarc we actually just released an update to our Preview extension which has addressed a Package Management bug, would you mind giving it a try and letting us know if you are still hitting this issue?
Good morning, installed the linked preview.
Got now the "=====> PowerShell Preview Integrated Console v2020.7.0 <====="
Unfortunately, after the VSC was restarted I got the message "The 'PowerShell' extension is recommended for this file type." following by "You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?"
If I click on "No" and press F5 for debugging my powershell code another message "Cannot debug or run a PowerShell script until the PowerShell session has started. Wait for the PowerShell session to finish starting and try again." appeared.
If I click on "Yes" the following code will be executed:
powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber -Repository PSGallery'
After the installation I got the message "PackageManagement updated, If you already had PackageManagement loaded in your session, please restart the PowerShell extension."
Now, the initial message "You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?" popups again and I repeated it as described above.
I've installed the preview and disabled the older version. When I opened a new project, I'm still seeing the prompt and installing the extension and restarting the PowerShell extension lands me in the same place (as @kaiaschulz outlines above).
@sympmarc what happens when you hit "yes"
Sorry, I probably wasn't clear. If I install PackageManagement and restart the extension, I'm right back to the same place. In other words, this latest extension preview doesn't change anything. I have the same experience as @kaiaschulz.
What version of PackageManagement do you have?
Before reinstalling PackageManagement:
Directory: C:\Program Files\WindowsPowerShell\Modules ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Command which runs:
powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'
After reinstalling PackageManagement:
Directory: C:\Program Files\WindowsPowerShell\Modules ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Before and after look the same to me...
Same as above.
Have you tried manually running that command? Does anything happen?
Sorry for the lag. I just ran the command manually. PackageManagement is definitely installed, whether I run the command manually or by clicking 'Yes' in the prompt. It's the standard teal progress indicator you see when you install any module.
I just tried to run through this as administrator, in case it mattered, but no difference. (I'm pretty sure I'd tried that already.)
When I get the prompt to restart the PowerShell Extension, I'm just clicking the garbage can on the terminal session, which reloads it. Should I be doing something different? A restart of VS Code altogether doesn't solve it, either.
After it ran, what does:
gmo -list PackageManagement
give you?
You should have a 1.4.7 somewhere in the PSModulePath:
https://www.powershellgallery.com/packages/PackageManagement/1.4.7
I wonder if running it with -Verbose
would shed any light. It seems very strange that the command runs, doesn't seem to fail, but does not install anything
The package version doesn't change. It's the same before and after updating.
The line it runs is this:
powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber -Repository PSGallery'
That's 1.4.6. For grins and giggles, I tried 1.4.7 - no difference.
Adding -Verbose
:
No idea why it would be installing to D:\OneDrive\Documents\WindowsPowerShell\Modules
Ok, next question: what is the result of $env:PSModulePath -split ';'
?
No idea why it would be installing to D:\OneDrive\Documents\WindowsPowerShell\Modules
What's the result of [environment]::getfolderpath('mydocuments')
?
As I suspected. PowerShellGet is using the special system folder API to guess the module install location, but PowerShell doesn't use that. Why I opened https://github.com/PowerShell/PowerShell/issues/7082.
I suspect the GetFolderPath()
result is because OneDrive has frustratingly mangled your settings.
The way to solve this in your case is to Save-Module PackageManagement -MinimumVersion 1.4.7 -LiteralPath 'C:\Users\mdent\Documents\WindowsPowerShell\Modules\
(may need to massage that command a bit).
I would say this is a bug in PowerShellGet, but given that this feature is intended to move old systems (that aren't going to get a new version of either PSGet or PackageManagement without help) off of an old (and by old I mean like 5 years old) module version that deadlocks us just by being loaded, we may need to think of a better strategy. Honestly, just being able to permanently dismiss the notification would be helpful. Especially if work I'm currently doing can prevent the deadlock on our end...
Thanks for sticking with us btw @sympmarc!
That fixed it! Hey, no problem. We're all in this together. Than you for sticking with me!
Hey. I still have the same issue as before even if the package version was already on 1.4.7 and located in the mentioned path C:\Users\%username%\Documents\WindowsPowerShell\Modules
above
[environment]::getfolderpath('mydocuments')
C:\Users\%username%\Documents
$env:PSModulePath -split ';'
C:\Users\%username%\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\PowerShell
C:\Program Files (x86)\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\PowerShell
C:\Program Files (x86)\AWS Tools\PowerShell\
C:\Program Files (x86)\Microsoft Azure Information Protection\Powershell
c:\Users\%username%\.vscode\extensions\ms-vscode.powershell-preview-2020.7.0\modules
In C:\Program Files (x86)\WindowsPowerShell\Modules
and C:\Program Files\WindowsPowerShell\Modules
was the old PackageManagement version 1.0.0.1
Regarding to this, I executed the mentioned command above for both pathes with administrative rights:
Save-Module PackageManagement -MinimumVersion 1.4.7 -LiteralPath 'C:\Program Files\WindowsPowerShell\Modules'
Save-Module PackageManagement -MinimumVersion 1.4.7 -LiteralPath 'C:\Program Files (x86)\WindowsPowerShell\Modules'
Afterwards the folders 1.4.7 were available.
Now, it seem to be fixed! Thanks a lot for all your help!
Nevertheless, why did the problem still persist even if the environment seem to be correctly set and the version was updated? [environment]::getfolderpath('mydocuments')
Nevertheless, why did the problem still persist even if the environment seem to be correctly set and the version was updated?
Your module path is different to the conventional default that PSGet expects — it seems strange that you have both x86 and normal module directories on the same module path; usually you only want either 32-bit or 64-bit locations on your module path.
My guess is that PSGet installed the module correctly to your 64-bit user path, but because the 32-bit path precedes it, you would always import the lower version out of preference. One way to fix that is to remove the lower versions of the module that appear when you run gmo -list PackageManagement
I have a different issue. It prompts repeatedly, but the version never updates.
gmo -list PackageManagement
before prompt:
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Output in console when updating:
powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'
WARNING: (0) : No source files specified
(1) : using System;
gmo -list PackageManagement
after:
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
What could be the cause of this?
Try opening a new powershell.exe
console and running Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber -Verbose
.
If you show us the full output of that, and if there's an error, $error[0] | fl * -force
, we might have a better chance of debugging it.
Output of Install-Module
:
WARNING: (0) : No source files specified
(1) : using System; VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories. VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'. VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'. VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'' for
''.
VERBOSE: Total package yield:'2' for the specified package 'PackageManagement'.
VERBOSE: Performing the operation "Install-Module" on target "Version '1.4.7' of module 'PackageManagement'".
VERBOSE: The installation scope is specified to be 'CurrentUser'.
VERBOSE: The specified module will be installed in 'C:\Users\Pika\Documents\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'PackageManagement' with version '1.4.7' from the repository
'https://www.powershellgallery.com/api/v2'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'' for
''.
VERBOSE: InstallPackage' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\1604792502'
VERBOSE: DownloadPackage' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\1604792502\PackageManagement\PackageManagement.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'.
VERBOSE: Completed downloading 'PackageManagement'.
VERBOSE: Hash for package 'PackageManagement' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\1604792502'
VERBOSE: Catalog file 'PackageManagement.cat' is not found in the contents of the module 'PackageManagement' being
installed.
VERBOSE: Valid authenticode signature found in the file 'PackageManagement.psd1' for the module 'PackageManagement'.
I didn't see an error in this output, but I ran $error[0] | fl * -force
anyways:
PSMessageDetails :
Exception : System.InvalidOperationException: Cannot add type. Compilation errors occurred.
at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord
errorRecord)
TargetObject :
CategoryInfo : InvalidData: (:) [Add-Type], InvalidOperationException
FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1: line 732
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
Running gmo -list PackageManagement
still shows 1.0.0.1
Looks like you're hitting an issue in PowerShellGet 1.0.0.1. Try updating PowerShellGet first: Install-Module PowerShellGet -AllowClobber -Scope CurrentUser -Force -Verbose
. Then you'll need to open a new PowerShell process and try installing PackageManagement again
Nope, that didn't work. Version is still 1.0.0.1
Can you show the result of gmo -list PowerShellGet
?
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Ok, I'm guessing you have a faulty PowerShellGet installation.
Try:
Expand-Archive ./PSGet.zip ./PowerShellGet
mkdir ~/Documents/WindowsPowerShell/Modules
(may error, not an issue)Move-Item ./PowerShellGet ~/Documents/WindowsPowerShell/Modules
The let us know what gmo -list PowerShellGet
outputs
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
How about $env:PSModulePath
C:\Users\Pika\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
ls ~/Documents/WindowsPowerShell/Modules
?
only directory there is PowerShellGet
Ok I'm assuming ~
maps to C:\Users\Pika
-- does gi ~ | % FullName
give you back C:\Users\Pika
?
What does gmo -list PowerShellGet -Verbose
look like?
Other thing to try is to take the downloaded, unzipped PowerShellGet
and import it directly with ipmo -Force ~/Documents/WindowsPowerShell/Modules/PowerShellGet
and confirm your version with gmo PowerShellGet
That fixed it! Hey, no problem. We're all in this together. Than you for sticking with me!
Unfortunately, while I thought this was "fixed" for me, it's still happening in some of my projects.
Ok I'm assuming ~ maps to C:\Users\Pika -- does gi ~ | % FullName give you back C:\Users\Pika?
Yes.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1'.
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Why do you think this is happening?
Ok rather than me try to give you individual commands to run, which I don't think is working well and is taking time away from other issues, I think it's best for me to give some general directions.
I both cases here I think your machines have some state or configuration that goes against the assumptions of the PackageManagement/PowerShellGet installations that currently exist on them. Specifically in one case PackageManagement is failing for some reason and needs to be replaced, and in the other PowerShellGet's assumptions about the module path are wrong. So our goal is to put your machines into a state where PackageManagement/PowerShellGet are up to date, work and are available on the PSModulePath.
To fix this, you need to:
Save-Module
. If that doesn't work on your local machine, the next easiest option is probably to use Save-Module
from another device and copy the asset over. If that's not an option, you can download the nupkg for the modules directly and use expand-archive
to restore them to module form.-noprofile
flag (easiest to start from CMD like powershell -noprofile
), import these modules by path from where you've downloaded themInstall-Module PackageManagement -MinimumVersion 1.4.7 -Verbose
and Install-Module PowerShellGet -MinimumVersion 2.2.4.1 -Verbose
to do a proper module installation$env:PSModulePath
has the directories where those modules were installed. If it doesn't, add a line in your $PROFILE
that prefixes the $env:PSModulePath
with the directory.gmo -List
Thanks for the detailed instructions.
I get to the point where I run Install-Module
, and this is the output:
VERBOSE: The installation scope is specified to be 'CurrentUser'.
VERBOSE: The specified module will be installed in 'C:\Users\Pika\Documents\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'PackageManagement' with version '1.4.7' from the repository
'https://www.powershellgallery.com/api/v2'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'' for
''.
VERBOSE: InstallPackage' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\111535631'
VERBOSE: DownloadPackage' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\111535631\PackageManagement\PackageManagement.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'.
VERBOSE: Completed downloading 'PackageManagement'.
VERBOSE: Hash for package 'PackageManagement' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\111535631'
VERBOSE: Catalog file 'PackageManagement.cat' is not found in the contents of the module 'PackageManagement' being
installed.
VERBOSE: Valid authenticode signature found in the file 'PackageManagement.psd1' for the module 'PackageManagement'.
C:\Users\Pika\Documents\WindowsPowerShell\Modules
is empty in the end, though...
I have permissions to create files and such in this folder...
What else could this be?
edit: same results if -Scope CurrentUser
is specified as well...
I assume the currently imported versions of PowerShellGet and PackageManagement are the right ones? What does gmo PowerShellGet
and gmo PackageManagement
tell you?
System Details
System Details Output
Issue Description
When I open a project, I am prompted with this probably 80% of the time. I've run it repeatedly, but it doesn't seem to make a difference.
If I click "Yes", this command is run"
Expected Behaviour
One prompt makes sense if I'm out of date. But it simply repeats.
Actual Behaviour
Too many prompts.