Issue Type: Bug
After installing PowerShell extension and opening a blank *.ps1 file, I immediately see the following exception in the Terminal window (PowerShell Integrated Console):
Unable to load DLL 'api-ms-win-core-sysinfo-l1-2-0.dll': The specified module could not be found.
Here's the (verbose) logs:
#-- Updated PSModulePath to: -------------------------------------------------
VERBOSE: C:\Users\<username>\Documents\WindowsPowerShell\Modules
VERBOSE: C:\Program Files\WindowsPowerShell\Modules
VERBOSE: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
VERBOSE: C:\Users\<username>\.vscode\extensions\ms-vscode.powershell-1.10.0\modules
VERBOSE:
#-- Check required modules available -----------------------------------------
VERBOSE: Testing module availability PowerShellGet
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1'.
VERBOSE: PowerShellGet found
VERBOSE:
#-- Start up PowerShellEditorServices ----------------------------------------
VERBOSE: Importing PowerShellEditorServices
VERBOSE: Loading module from path 'C:\Users\<username>\.vscode\extensions\ms-vscode.powershell-1.10.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'.
VERBOSE: Loading module from path 'C:\Users\<username>\.vscode\extensions\ms-vscode.powershell-1.10.0\modules\PowerShellEditorServices\PowerShellEditorServices.psm1'.
VERBOSE: Exporting function 'Start-EditorServicesHost'.
VERBOSE: Exporting function 'Compress-LogDir'.
VERBOSE: Exporting function 'Get-PowerShellEditorServicesVersion'.
VERBOSE: Importing function 'Compress-LogDir'.
VERBOSE: Importing function 'Get-PowerShellEditorServicesVersion'.
VERBOSE: Importing function 'Start-EditorServicesHost'.
PowerShell Integrated Console
VERBOSE: Invoking Start-EditorServicesHost
VERBOSE: ERRORS caught starting up EditorServicesHost
VERBOSE: Exception calling "StartLogging" with "2" argument(s): "Unable to load DLL 'api-ms-win-core-sysinfo-l1-2-0.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
at System.Management.Automation.CommandProcessorBase.Complete()
Unable to load DLL 'api-ms-win-core-sysinfo-l1-2-0.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Interop.mincore.GetNativeSystemInfo(SYSTEM_INFO& lpSystemInfo)
at System.Runtime.InteropServices.RuntimeInformation.get_OSArchitecture()
at Microsoft.PowerShell.EditorServices.Host.EditorServicesHost.StartLogging(String logFilePath, LogLevel logLevel)
at CallSite.Target(Closure , CallSite , Object , Object , Object )
Following this, a popup informs me "The language service could not be started", with the output showing:
12/6/2018 8:04:32 AM [NORMAL] - Visual Studio Code v1.29.1 64-bit
12/6/2018 8:04:32 AM [NORMAL] - PowerShell Extension v1.10.0
12/6/2018 8:04:32 AM [NORMAL] - Operating System: Windows 64-bit
12/6/2018 8:04:32 AM [NORMAL] - Path specified by 'powerShellExePath' setting - '' - not found, reverting to default PowerShell path.
12/6/2018 8:04:32 AM [NORMAL] - Language server starting --
12/6/2018 8:04:32 AM [NORMAL] - exe: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
12/6/2018 8:04:32 AM [NORMAL] - args: C:\Users\<username>\.vscode\extensions\ms-vscode.powershell-1.10.0\modules\PowerShellEditorServices\Start-EditorServices.ps1 -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.10.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\<username>\.vscode\extensions\ms-vscode.powershell-1.10.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\<username>\.vscode\extensions\ms-vscode.powershell-1.10.0\logs\1544079872-16daafe7-886f-4c9b-a9b0-0f679d62a7f51544079869517\EditorServices.log' -SessionDetailsPath 'C:\Users\<username>\.vscode\extensions\ms-vscode.powershell-1.10.0\sessions\PSES-VSCode-6216-312941' -FeatureFlags @()
12/6/2018 8:04:33 AM [NORMAL] - powershell.exe started, pid: 15068
12/6/2018 8:06:32 AM [NORMAL] - Language server startup failed.
12/6/2018 8:06:32 AM [ERROR] - The language service could not be started:
12/6/2018 8:06:32 AM [ERROR] - Timed out waiting for session file to appear.
12/6/2018 8:09:33 AM [NORMAL] - powershell.exe terminated or terminal UI was closed
General Info
|Name|Value|
|--- |---|
|Extension version|1.10.0|
|VS Code version|Code 1.29.1 (bc24f98b5f70467bc689abf41cc5550ca637088e, 2018-11-15T19:13:36.375Z)|
|OS version|Windows_NT x64 6.1.7601 (Windows 7)|
$PSVersionTable
|Name|Value|
|--- |---|
|PSVersion|5.1.14409.1012|
|PSEdition|Desktop|
|PSCompatibleVersions|{1.0, 2.0, 3.0, 4.0...}|
|BuildVersion|10.0.14409.1012|
|CLRVersion|4.0.30319.42000|
|WSManStackVersion|3.0|
|PSRemotingProtocolVersion|2.3|
|SerializationVersion|1.1.0.1|
VS Code Info
|Item|Value|
|---|---|
|Version|1.29.1 (user setup)|
|Commit|bc24f98b5f70467bc689abf41cc5550ca637088e|
|Date|2018-11-15T19:13:36.375Z|
|Electron|2.0.12|
|Chrome|61.0.3163.100|
|Node.js|8.9.3|
|V8|6.1.534.41|
|Architecture|x64|
System Info
|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz (8 x 2712)|
|GPU Status|2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled|
|Memory (System)|15.88GB (3.36GB free)|
|Process Argv||
|Screen Reader|no|
|VM|75%|
That is rather strange. I assume you can start Windows PowerShell fine?
Can you give the output of ls $PSHOME?
Yes, PowerShell is working fine otherwise.
Here's ls $PSHOME output:
Directory: C:\WINDOWS\System32\WindowsPowerShell\v1.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 20.04.2018 15:21 de
d----- 20.04.2018 15:21 de-DE
d----- 20.04.2018 15:21 en
d----- 20.04.2018 15:21 en-US
d----- 23.05.2017 13:13 Examples
d----- 20.04.2018 15:21 Modules
d----- 23.05.2017 13:13 Schemas
d----- 23.05.2017 13:13 SessionConfig
-a---- 03.10.2016 08:49 12825 Certificate.format.ps1xml
-a---- 03.10.2016 08:49 5074 Diagnostics.Format.ps1xml
-a---- 03.10.2016 08:49 138223 DotNetTypes.format.ps1xml
-a---- 03.10.2016 08:49 10144 Event.Format.ps1xml
-a---- 03.10.2016 08:49 25526 FileSystem.format.ps1xml
-a---- 03.10.2016 08:49 9164 getevent.types.ps1xml
-a---- 03.10.2016 08:49 91655 Help.format.ps1xml
-a---- 03.10.2016 08:49 138625 HelpV3.format.ps1xml
-a---- 09.12.2016 03:34 443392 powershell.exe
-a---- 03.10.2016 08:49 206468 PowerShellCore.format.ps1xml
-a---- 03.10.2016 08:49 4097 PowerShellTrace.format.ps1xml
-a---- 09.12.2016 20:45 212992 powershell_ise.exe
-a---- 27.10.2016 02:49 363 powershell_ise.exe.config
-a---- 09.12.2016 03:37 55808 PSEvents.dll
-a---- 16.09.2013 09:12 174592 pspluginwkr.dll
-a---- 09.12.2016 03:34 2560 pwrshmsg.dll
-a---- 09.12.2016 03:36 29184 pwrshsip.dll
-a---- 03.10.2016 08:49 8458 Registry.format.ps1xml
-a---- 03.10.2016 08:49 210376 types.ps1xml
-a---- 03.10.2016 08:49 12282 typesv3.ps1xml
-a---- 03.10.2016 08:49 16598 WSMan.Format.ps1xml
One more followup question: have you been successfully using the extension before and the new release caused this bug?
If there are any other configurations, paths, or stack traces you can tell us about, or any other possibly relevant information, that would be very handy
I'm going to look into this in the next week. @adityapatwardhan, @daxian-dbw, @SteveL-MSFT I might need your insight.
I'm new to PowerShell, so I just installed the extension for the first time.
I can't think of much more that would help...
Perhaps that I just clicked the 'install suggested extension' button without adding any extra config files etc.
It's also a work computer, so may have had certain security policies and/or various PS upgrades applied over time.
Searching for api-ms-win-core-sysinfo-l1-2-0.dll turns up a few other people with a similar error, although not in VS Code. I have various versions of this DLL on my system, including in
C:\Users\<username>\AppData\Local\Programs\Microsoft VS Code\api-ms-win-core-sysinfo-l1-1-0.dll
and C:\Windows\System32\api-ms-win-core-sysinfo-l1-1-0.dll
Both of which are v1.1, not the requested v1.2
Do let me know if I can be of further assistance.
I do have same problem with PowerShell Extension in VSCode. The problem starts this morning after reload of vscode to
Version: 1.29.1 (system setup)
Commit: bc24f98b5f70467bc689abf41cc5550ca637088e
Date: 2018-11-15T19:13:36.375Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64
I found 'api-ms-win-core-sysinfo-l1-2-0.dll' on another machine. I added the file to 'C:\Program Files\Microsoft VS Code' with no succes even after restart vscode. I add 'api-ms-win-core-sysinfo-l1-2-0.dll' to 'C:\Windows\System32' with succes.
Everything looks fine, but there is still an error in EditorServices.log
My Diagnostic logfiles are
EditorServices.log
Start-EditorServices-EditorServices.log
vscode-powershell.log
attached.
I am seeing the same issue, starting this morning with the new 1.10.0 update of ms-vscode.powershell
Yesterday the 1.9.0 version was working without issue.
I couldn't identify where the StartLogging method call was being used in this project, so I couldn't investigate further. But it appears to depend on the api-ms-win-core-sysinfo-l1-2-0.dll file to be available.
EDIT: Following this link, I was able to downgrade back to v1.9.0, and it is working again.
https://tpodolak.com/blog/2017/04/09/downgrading-visual-studio-code-extension/
Also, to prevent reinstalling v1.10.0, uncheck the following setting in vscode:
Extensions: Auto Update
or
"extensions.autoUpdate": false
Ok I'm looking into this. Hoping to get it fixed in the next week.
We ship the DLL from this nuget package to log OSArchitecture among other things.
We have to reassemble the DLLs in the module ourselves to make it cross platform. You'll see that here.
If you manage locate the right DLL on your machine, it needs to go ~\.vscode\extensions\ms-vscode.powershell-1.10.0\modules\PowerShellEditorServices\bin\Desktop\. When the EditorServices DLLs are loaded, .NET automatically looks for dependencies in the same directory. I want to disrecommend downloading DLLs from the internet, since they could contain and do anything.
This should be possible to accomplish at build time for us as soon as I work out what the best way of going about this is.
Looks like this is https://github.com/dotnet/corefx/issues/13566.
I'm looking into where to get the appropriate DLL.
Here's the required file for now, taken from the nuget package. You can unzip it and put it into ~/.vscode/extensions/ms-vscode.powershell-1.10.0/modules/PowerShellEditorServices/bin/Desktop:
(GitHub doesn't allow non-zip attachments)
I will add this to our build as well. I anticipate a bugfix release in the next week or two.
@gtaylor1981 Thanks for all the info you provided too. That stack trace was invaluable.
I've spent quite a while looking through this and haven't been able to make much sense of it. I've opened up a new issue in corefx, as linked above.
I had this issue as well but only on my Windows 7 SP1 desktop but not on MacOS.
I think this is a fluke solution I found though - I upgraded the .Net Framework from 4.6 to 4.7.2 and that solved it for me. I am using VSCode 1.29.1 with WMF 5.1 on Windows 7 SP1. After the upgrade, it worked just fine.
We've released a fix for this in https://github.com/PowerShell/PowerShellEditorServices/pull/808.
This is a Windows 7 specific problem that occurs because of a strange hole in a .NET API we depended on. We've worked around that issue now, but I also recommend upgrading your .NET version to at least 4.7.2 if possible (that's got all the cross-platform APIs built in).
Please comment here if you still experience problems.
I just updated to v1.10.1 and everything's working well. Thanks for the quick response!
Glad to hear, @gtaylor1981!
The response I've gotten from corefx is that we should upgrade to .NET Standard 2.0, which is .NET Framework 4.6.1 equivalent.
We've already done this downstream in the 2.0.0 build, so I think we should invest there.
Most helpful comment
I just updated to v1.10.1 and everything's working well. Thanks for the quick response!