I just installed poshgit. Now every time I open a powershell prompt I get the following. I try cinst -force poshgit and I still get the same error.
Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.
At C:\Users\swarwick\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:1 char:66
I'm having the same problem. I can't seem to find any solutions online. Did you find a solution?
I had this issue too. I changed my file to look like this:
Make sure you check out the last line and fix the REPLACEME text
I had the same problem. It turned out for me that all the lines in
C:\Users[UserName]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
were bunched together in one line. Its like all the new-lines were missing.
I separated it out like this and it fixed it:
Rename-Item Function:\Prompt PoshGitPrompt -Force
function Prompt() {
if(Test-Path Function:\PrePoshGitPrompt){
++$global:poshScope;
New-Item function:\script:Write-host -value "param([object] $object,$backgroundColor, $foregroundColor, [switch]$nonewline) " -Force | Out-Null;
$private:p = PrePoshGitPrompt;
if(--$global:poshScope -eq 0) {
Remove-Item function:\Write-Host -Force
}
}
PoshGitPrompt
}
I got the same issue, but RobAhnemann SunsetQuest's tip fixed it. Thanks!
In other words I edited this bit of code PoshGitPrompt -Forcefunction Prompt() as PoshGitPrompt -Force function Prompt(), with a space between "-Force" and "function".
I ran into this as well trying to follow along with the Microsoft Virtual Academy series on VS and Git here.
Must be a line-ending encoding issue?
That's exactly were I ran into it also. (http://www.microsoftvirtualacademy.com/training-courses/using-git-with-visual-studio-2013-jump-start) It's possible something changed since the original post date.
I'll look into this as part of #184 (fixing the Chocolate package). Sorry for your troubles, hopefully the workaround has gotten you by so far.
@SunsetQuest It worked out perfectly, I wonder how you knew that was what to do
@tobitech I found the failing script (I think i got the name/location from the opening post) so I thought I would take a quick gander inside and then noticed everything was bunched on one line.
I've confirmed this issue is specific to installs when the $PROFILE file does not already exist. Pretty sure the problem is that this line isn't actually returning a string[] so Insert-Script is using string concatenation instead of array concatenation.
Should be an easy fix.
I tried recreating this by deleting $PROFILE and wasn't able to. It seems to only happen when git is not installed while attempting to install poshgit. This seemed really weird to me so I tried it a few times, along with clearing out %programdata%/chocolatey/lib as well as $PROFILE and it reproduced consistently.
I wasn't able to test it with what's in master as chocolatey didn't want to resolve dependencies when installing from a nuspec file and reproducing this seemed to require that.
Perhaps the git.install package sets some global configuration for newlines?
It's worth noting that I didn't try this with an existing $PROFILE
I've updated #184 with a tentative fix that is awaiting Chocolatey moderation. I believe you can try it today with choco install poshgit -version 0.5.2.20150825.
FYI I just encountered this exact issue after installing poshgit from chocolatey. Installed version is 0.6.0.20160310. @SunsetQuest's workaround still solves the problem.
Sigh. I forgot that 0.5.2 had shipped without actually merging #184. I just published 0.6.1, pending moderation. Please let me know if that doesn't resolve the issue.
@dahlbyk I believe we can close this as the prompt override goes away with #358.
I was having this problem but then I realized I forgot to put a ":" after defining a function.
Most helpful comment
I had this issue too. I changed my file to look like this:
http://pastebin.com/Ky3xJXpL
Make sure you check out the last line and fix the REPLACEME text