Skip to content

Prompt script block System.NullReferenceException #602

@annahosanna

Description

@annahosanna
  • posh-git version/path: 0.7.3.1 C:\tools\poshgit\dahlbyk-posh-git-9bda399\src
  • PowerShell version: 4.0
  • git version 2.18.0.windows.1
  • OS: Microsoft Windows NT 6.1.7601 Service Pack 1

Posh-git installed via Chocolatey

After posh-git install Powershell prompt appeared as:
PS>

It seems that there was an issue setting currentPath within the prompt script block:
$currentPath = $ExecutionContext.SessionState.InvokeCommand.ExpandString($GitPromptSettings.DefaultPromptPath);

Object reference not set to an instance of an object.
+ CategoryInfo : OperationStopped: (:) [], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException

However DefaultPromptPath seems to be defined:
write-host $global:GitPromptSettings.DefaultPromptPath
$(Get-PromptPath)

To resolve the issue I was able to redefine the prompt function with an updated prompt script block in the profile, after importing the posh-git module, by updating this single line:
$currentPath = $(Get-PromptPath)

Is there a better way to resolve this?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions