Skip to content
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

"Error An expression was expected after '('or on" whenever I open a powershell prompt #180

Closed
SteveWarwick opened this issue Mar 13, 2015 · 16 comments

Comments

@SteveWarwick
Copy link

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

  • Rename-Item Function:\Prompt PoshGitPrompt -Forcefunction Prompt() {if(Test-Path ...
  •                                                              ~
    
    An expression was expected after '('.
    • CategoryInfo : ParserError: (:) [], ParseException
    • FullyQualifiedErrorId : ExpectedExpression
@mkerchenski
Copy link

I'm having the same problem. I can't seem to find any solutions online. Did you find a solution?

@RobAhnemann
Copy link

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

@SunsetQuest
Copy link

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
}

@javlc
Copy link

javlc commented Apr 23, 2015

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".

@davidmarcbrown
Copy link

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?

@SunsetQuest
Copy link

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.

@dahlbyk
Copy link
Owner

dahlbyk commented May 14, 2015

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.

@tobitech
Copy link

tobitech commented Jun 1, 2015

@SunsetQuest It worked out perfectly, I wonder how you knew that was what to do

@SunsetQuest
Copy link

@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.

@dahlbyk
Copy link
Owner

dahlbyk commented Jun 1, 2015

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.

@jjoekoullas
Copy link

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

@dahlbyk
Copy link
Owner

dahlbyk commented Aug 25, 2015

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.

@davecan
Copy link

davecan commented Mar 29, 2016

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.

@dahlbyk
Copy link
Owner

dahlbyk commented Mar 30, 2016

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.

@rkeithhill
Copy link
Collaborator

@dahlbyk I believe we can close this as the prompt override goes away with #358.

@arlosanc
Copy link

I was having this problem but then I realized I forgot to put a ":" after defining a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests