-
Notifications
You must be signed in to change notification settings - Fork 490
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
Powershell: Initialization Error #603
Comments
Looks like we might also have a logging bug where we are not appending a |
Oooop. No Keith, that's my bad - I manually edited that output to obfuscate my username in this publicly visible post... |
New version of VSCode installed - March 2017 (version 1.11) System Details |
New version of VSCode installed - May 2017 (version 1.12.2) New logs attached |
Thanks @cmcknz77! There's definitely an exception happening during initialization that we're not capturing in a way that you can observe. Can you try these steps:
Hopefully an error will be printed so that we can see what exception you're getting. This improvement to the Start-EditorServices script will be included with the next extension update. |
Thanks @daviwil . I had same issue with VScode on linux. That did the trick for me! |
@Ghoshnik interesting, this script shouldn't have fixed anything, it just prints out more diagnostic information. Can you tell me what version of PowerShell Core you're using on Linux? |
Weird. Name Value PSVersion 6.0.0-beta |
Thanks! That's the right version to use for now. What was happening before, the Integrated Console just wouldn't start? I'll have to look at my script change a little more closely to see if there's an explanation for why it might have resolved that. |
@daviwil Is this the "diagnostic information" your modified
I was getting the Language Server failures this morning and tried your modified script, it seems to have fixed the issue as well, even though I understand it's supposed to just explain it better. |
@xandora I was referring to error output in the Integrated Console if there was a crash on startup. The latest version of the PowerShell extension (1.2.1) includes this updated script, were you seeing the startup crash there too before using the script I linked to? My suspicion is that the problem is being caused by the Start-EditorServices.ps1 script being signed in the official releases. If any of you have a few moments, could you uninstall/reinstall the PowerShell extension and then run the official Start-EditorServices.ps1 script inside of PowerShell.exe? You don't need to worry about the parameters, what I'm looking for is whether you get prompted about whether you want to run a signed script (Run Once should be one of the options). Thanks! |
I'm having the same (or similar) problem. I get "Starting Powershell..." in the lower right forever. My log is attached. I've re-installed the 1.3.2 extension. What else can I try? Thanks! |
@andrewlathom could you turn on verbose logging and send new logs? https://github.com/PowerShell/vscode-powershell#2-capture-verbose-logs-and-send-them-to-us The current log is helpful but I'm not getting the full picture. Thanks! |
Here you go - thanks for looking at them -Andy |
Strange that you'd see "Starting PowerShell" forever since it seems that your session has loaded successfully. Looks like you started the debugger at the end of the logs, was the debugger working for you after you did that or did it seem to hang? |
Whenever I try to start a script, either with or without the debugger, it doesn't run. I get the little Pause/Stop floating bar, but nothing executes. |
@daviwil Cross-posted in #572 after enabling verbose logging and replacing Start-EditorServices.ps1 with https://raw.githubusercontent.com/daviwil/vscode-powershell/eb8b2d31d2fafe5e2e09cdfed7f811c74d9d1bcf/scripts/Start-EditorServices.ps1 Thanks again! EDIT 6-22-17 |
Hi. I'm new here, so I hope I'm not violating any unwritten rules or stepping on any toes. I'm a Windows admin by trade and don't know jack-squat about development, so I apologize if I'm not expressing myself properly. I'm having what I think is the same problem. VSCode itself starts okay but as soon as I open an existing file or try to start a new one I get an error ‘The language service could not be started’. I also get a 'PowerShell Initialization Error' message in the bottom right corner of the VSCode window. I uninstalled and reinstalled everything from scratch this afternoon, but apparently I didn't even do that properly since the few customizations I made were retained. Is there a solution for this yet? My understanding of the previous posts is that the replacement script @daviwil linked is supposed to gather diagnostic data and isn't actually a fix. Thanks, regardless. PS 5, W10 64-bit Ent, VSC 1.14.2 64-bit |
I didn't have all the same symptoms you mentioned, but the suggestions in
this thread cleared up my issue.
#742 (comment)
…-Andy
On Fri, Jul 21, 2017 at 3:52 PM, CharlesSpencer ***@***.***> wrote:
Hi. I'm new here, so I hope I'm not violating any unwritten rules or
stepping on any toes. I'm a Windows admin by trade and don't know
jack-squat about development, so I apologize if I'm not expressing myself
properly.
I'm having what I think is the same problem. VSCode itself starts okay but
as soon as I open an existing file or try to start a new one I get an error
‘The language service could not be started’. I also get a 'PowerShell
Initialization Error' message in the bottom right corner of the VSCode
window. I uninstalled and reinstalled everything from scratch this
afternoon, but apparently I didn't even do that properly since the few
customizations I made were retained.
Is there a solution for this yet? My understanding of the previous posts
is that the replacement script @daviwil <https://github.com/daviwil>
linked is supposed to gather diagnostic data and isn't actually a fix.
Thanks, regardless.
PS 5, W10 64-bit Ent, VSC 1.14.2 64-bit
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#603 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AcHhddUlznaN9vIDi2ngNXFomgQU_Sagks5sQQFxgaJpZM4Ml_fL>
.
|
Had similar symptoms; in my case, it appears to be related to antivirus. McAfee had this to say in my Windows Application Event Log:
I'll be taking it up with my AV admin. |
Bizarrely for me this problem appears to have disappeared after updateing to the latest VSCode code... |
Just wanted to check in since a few folks had their issues resolved. Is anyone else still having issues? I'd love some fresh logs if you have them. Thanks! |
Thanks for following up... My issue persisted until my IT department added an exclusion in McAfee Endpoint Security's Exploit Prevention module that allows winpty-agent.exe to call PowerShell.exe using the AtlComPtrAssign API. I don't know if it's possible to change the way the PowerShell console is launched inside of VS Code that makes it more friendly towards McAfee (and possibly other AV products), but I anticipate other McAfee users may run into similar issues in future. |
System Details
Issue DescriptionWhen I open a .ps1 file, then get a notice that says 'Initialization Error' in the vscode bottom. The detail log is:
I change the setting "powershell.developer.editorServicesLogLevel" to "Verbose", and restart vscode, but there is no verb outputs, nothing changed. I think the Start-EditorServices.ps1 doesn't even run. I manually run it like below:
And get some error logs:
What can I do? |
@amitbha I see you're using Arch. Has the extension ever worked for you? @rkeithhill your extra logging is working :)
|
@tylerl0706 My first time using vscode-powershell extension. It has never worked properly. |
@amitbha: That's what I figured... this could very well be a PowerShell or .NET Core issue. We'll have to look deeper. |
RE: winpty-agent.exe to call PowerShell.exe using the AtlComPtrAssign API Are you able to see if the PowerShell terminal that ships with VSCode works? In other words, not the PowerShell Integrated Console in VSCode, but the normal PowerShell console in VSCode. |
@amitbha I'm not on Arch so it's going to be difficult to repro so I'm going to need your help. Here's the function that tests the availability of a port: function Test-PortAvailability {
param(
[Parameter(Mandatory=$true)]
[int]
$PortNumber
)
$portAvailable = $true
try {
if ($isPS5orLater) {
$ipAddresses = [System.Net.Dns]::GetHostEntryAsync("localhost").Result.AddressList
}
else {
$ipAddresses = [System.Net.Dns]::GetHostEntry("localhost").AddressList
}
foreach ($ipAddress in $ipAddresses)
{
Log "Testing availability of port ${PortNumber} at address ${ipAddress} / $($ipAddress.AddressFamily)"
$tcpListener = New-Object System.Net.Sockets.TcpListener @($ipAddress, $PortNumber)
$tcpListener.Start()
$tcpListener.Stop()
}
}
catch [System.Net.Sockets.SocketException] {
$portAvailable = $false
# Check the SocketErrorCode to see if it's the expected exception
if ($_.Exception.SocketErrorCode -eq [System.Net.Sockets.SocketError]::AddressAlreadyInUse) {
Log "Port $PortNumber is in use."
}
else {
Log "SocketException on port ${PortNumber}: $($_.Exception)"
}
}
$portAvailable
} Can you tell me the exact line that causes the exception? You will probably need to remove the try/catch. Let me know if you need help. |
@tylerl0706 I remove the try/catch, and the error message is:
|
I print the parameters before tcpListener: write-host "$ipAddress, $PortNumber"
$tcpListener = New-Object System.Net.Sockets.TcpListener @($ipAddress, $PortNumber)
$tcpListener.Start()
$tcpListener.Stop() and the ouput is:
|
@amitbha: So do all of those values throw the exception? |
@tylerl0706 |
@amitbha I think this might be a bug on the .NET Core team. For some reason, it's having a hard time listening on ports. Here's what I think you should do: if you have the dotnet sdk installed on your Arch machine:Create a small C# console app that just does the following: var tcpListener = new System.Net.Sockets.TcpListener("127.0.0.1", "12179");
tcpListener.Start();
tcpListener.Stop();
var tcpListener = new System.Net.Sockets.TcpListener("::1", "12179");
tcpListener.Start();
tcpListener.Stop(); I might not have the syntax perfectly. If you DON'T have the dotnet sdk installed on your Arch machine:Just use PowerShell $tcpListener = New-Object System.Net.Sockets.TcpListener @("127.0.0.1", "12179")
$tcpListener.Start()
$tcpListener.Stop()
$tcpListener = New-Object System.Net.Sockets.TcpListener @("::1", "12179")
$tcpListener.Start()
$tcpListener.Stop() Put that code and the exception thrown in a new issue here: along with anything else they need. If you're using the PowerShell example, mention that you're only using PowerShell because you don't have the .NET sdk installed. Also, be sure to link this issue with that issue. |
@tylerl0706 Thanks for your patience. This code exactly find where the problem is: 1 $tcpListener = New-Object System.Net.Sockets.TcpListener @("127.0.0.1", "12179")
2 $tcpListener.Start()
3 $tcpListener.Stop()
4
5 $tcpListener = New-Object System.Net.Sockets.TcpListener @("::1", "12179")
6 $tcpListener.Start()
7 $tcpListener.Stop() Line 6 throws the exception:
I remember that, I disabled ipv6 on all network interfaces in sysctl.conf like this: So, bug or not? |
@amitbha Can you test this code: function Log([string[]]$msg) {
$msg | Write-Verbose
}
function Test-PortAvailability {
param(
[Parameter(Mandatory=$true)]
[int]
$PortNumber
)
if ($isPS5orLater) {
$ipAddresses = [System.Net.Dns]::GetHostEntryAsync("localhost").Result.AddressList
}
else {
$ipAddresses = [System.Net.Dns]::GetHostEntry("localhost").AddressList
}
foreach ($ipAddress in $ipAddresses)
{
try {
Log "Testing availability of port ${PortNumber} at address ${ipAddress} / $($ipAddress.AddressFamily)"
$tcpListener = New-Object System.Net.Sockets.TcpListener @($ipAddress, $PortNumber)
$tcpListener.Start()
$tcpListener.Stop()
return $ipAddress
}
catch [System.Net.Sockets.SocketException] {
# Check the SocketErrorCode to see if it's the expected exception
if ($_.Exception.SocketErrorCode -eq [System.Net.Sockets.SocketError]::AddressAlreadyInUse) {
Log "Port $PortNumber is in use."
}
else {
Log "SocketException on port ${PortNumber}: $($_.Exception)"
}
}
}
$null
}
Test-PortAvailability 12179 The problem is that we test both ipv4 and ipv6 and if either of those fail, then we fail the port. That is not correct. Whichever one succeeds first, we should indicate that port is available but not only that the port is available but which address family we should use to connect. Hence the above returns |
@rkeithhill The code runs well. The output is:
BTW, strangely, the |
I updated the 'Start-EditorServices.ps1' with the new code, and open the vscode In hope. But the problem 'Language server startup failed' persisted. I copy the command in output and manually run it ike below:
And the session file is created sucessfully! Its content is:
👽 |
Thanks for trying that. I'll submit a PR later tonight for this change to the script. The callsite for the Test-Availability function has to change to capture the IP address and pass it up to its caller. |
@rkeithhill didn't we recently make a change to check for IP v6 as well as IP v4 because sometimes a port was already taken with IP v6 but would show available to IP v4? |
Yup and this proves that one of the two primary address families may not be available on a machine. Now need to fix it to handle that case without failing. :-) |
Fix #603 where system has ipv6 addresses disabled. This is also more consistent with the PSES TCP listener which always [IPAddress]::Loopback as the IP address.
@amitbha The fix will be included in the next release - going out next week. |
logs.zip
System Details
$PSVersionTable
:Name Value
PSVersion 5.1.14393.953
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.953
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
When I open a file with a recognised 'Powershell' extension (.ps1,.psm1,*.psd1 etc) or having typed in some script I tell 'Code' that the language is 'PowerShell' instead of plain text, I get a notice that says 'Initialization Error' in the bottom right hand corner.
When I click on it I get an error in the Error bar that says "Error: Could not start language service:"
And if I click on the logs I see the following:
[0:2:23] Language server starting...
powershell.exe started --
pid: 928
exe: C:\WINDOWS\Sysnative\WindowsPowerShell\v1.0\powershell.exe
args: C:\Users\myuser\.vscode\extensions\ms-vscode.PowerShell-0.10.1\scripts\Start-EditorServices.ps1 -EditorServicesVersion '0.10.1' -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '0.10.1' -BundledModulesPath 'C:\Users\myuser\.vscode\extensions\ms-vscode.PowerShell-0.10.1\modules' -EnableConsoleRepl -LogLevel 'Verbose' -LogPath 'C:\Users\myuser\.vscode\extensions\ms-vscode.PowerShell-0.10.1\logs\1490227343-bdec66a5-f1e8-4d56-9ce5-5e057642a56f1490227309017\EditorServices.log' -SessionDetailsPath 'C:\Users\myuser\.vscode\extensions\ms-vscode.PowerShell-0.10.1\sessions\PSES-VSCode-10944'
powershell.exe terminated or terminal UI was closed
[0:3:23] Language server startup failed.
Could not start language service:
Timed out waiting for session file to appear.
Now... I'm in a Domain environment where our Security Policy forced down from 'on high' by Group Policy is that we're in an allsigned environment. I have tried Code and the Powershell Extension on a number of machines now and I always get the same experience.
Incidentally, it appears that the module files:
modules\Plaster\Templates\NewPowerShellManifestModule\Module.psm1
modules\Plaster\Templates\NewPowerShellManifestModule\test\Module.T.ps1
are not signed - I don't know if this is related.
Attached Logs
logs.zip
The text was updated successfully, but these errors were encountered: