Skip to content

GetVersionDetails failing due to empty $env:PROCESSOR_ARCHITECTURE #346

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
rkeithhill opened this issue Jan 19, 2017 · 4 comments
Closed
Labels
Issue-Bug A bug to squash.
Milestone

Comments

@rkeithhill
Copy link
Contributor

Just looking at a log file and noticed this:

1/18/2017 8:12:05 PM [NORMAL] - Method "StartLogging" at line 117 of C:\Users\Keith\GitHub\rkeithhill\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs

    PowerShell Editor Services Host v0.0.0.0 starting (pid 22828)...
    
      Host application details:
    
        Name:      Visual Studio Code Host
        ProfileId: Microsoft.VSCode
        Version:   0.8.0
        Arch:      64-bit
    
      Operating system details:
    
        Version: Microsoft Windows NT 10.0.14393.0
        Arch:    64-bit

1/18/2017 8:12:05 PM [WARNING] - Method "GetVersionDetails" at line 149 of C:\Users\Keith\GitHub\rkeithhill\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellVersionDetails.cs

    Failed to look up PowerShell version, defaulting to version 5.
    
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.PowerShellContext.<>c__47`1.<ExecuteScriptAndGetItem>b__47_0(PSObject pso)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.<OfTypeIterator>d__92`1.MoveNext()
       at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
       at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteScriptAndGetItem[TResult](String scriptToExecute, Runspace runspace, TResult defaultValue)
       at Microsoft.PowerShell.EditorServices.Session.PowerShellVersionDetails.GetVersionDetails(Runspace runspace)

This on latest bits updated just a little while ago.

@daviwil
Copy link
Contributor

daviwil commented Jan 19, 2017

Haha, wow, I actually broke it on the VS Code side by sending an empty environment variables object to the process, must have cleared out all the env vars completely.

@daviwil daviwil changed the title GetVersionDetails failing GetVersionDetails failing due to empty $env:PROCESSOR_ARCHITECTURE Jan 19, 2017
@daviwil daviwil added the Issue-Bug A bug to squash. label Jan 19, 2017
@daviwil daviwil added this to the 0.9.0 milestone Jan 19, 2017
@rkeithhill
Copy link
Contributor Author

Yeah, probably good to get that fixed before the release. :-)

daviwil added a commit to PowerShell/vscode-powershell that referenced this issue Jan 19, 2017
This change fixes an issue where $env:PROCESSOR_ARCHITECTURE is not being
set properly in the language server's powershell.exe process which caused
an exception when gathering that variable.  The problem was caused by the
environment variable setting behavior when the Windows PowerShell
developer build setting is set to false.  In this case, an empty
environment variable object was being passed to the process, effectively
clearing its environment variables.

This is one half of the fix to PowerShell/PowerShellEditorServices#346.
daviwil added a commit that referenced this issue Jan 19, 2017
Fix #346: GetVersionDetails failing due to empty environment variable
@mrward
Copy link

mrward commented Jan 29, 2017

I am seeing a similar NullReferenceException on the Mac using:

  • PowerShell Editor Services 0.9.0
  • Visual Studio Code 1.8.1
  • PowerShell Core: v6.0.0-alpha.14
01/29/2017 10:17:17 [NORMAL] - Method "StartLogging" at line 117 of C:\dev\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs

    PowerShell Editor Services Host v0.0.0.0 starting (pid 613)...
    
      Host application details:
    
        Name:      Visual Studio Code Host
        ProfileId: Microsoft.VSCode
        Version:   0.9.0
    

01/29/2017 10:17:18 [WARNING] - Method "GetVersionDetails" at line 152 of C:\dev\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellVersionDetails.cs

    Failed to look up PowerShell version, defaulting to version 5.
    
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.PowerShellContext.<>c__47`1.<ExecuteScriptAndGetItem>b__47_0(PSObject pso)
       at System.Linq.Enumerable.SelectIListIterator`2.MoveNext()
       at System.Linq.Enumerable.<OfTypeIterator>d__33`1.MoveNext()
       at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
       at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteScriptAndGetItem[TResult](String scriptToExecute, Runspace runspace, TResult defaultValue)
       at Microsoft.PowerShell.EditorServices.Session.PowerShellVersionDetails.GetVersionDetails(Runspace runspace)

@daviwil
Copy link
Contributor

daviwil commented Jan 29, 2017

Thanks for letting me know! I'll get a patch update shipped in a few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

3 participants