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

Can't install latest release #381

Closed
ownmaster opened this issue Jan 29, 2017 · 32 comments · Fixed by #383, #384 or #390
Closed

Can't install latest release #381

ownmaster opened this issue Jan 29, 2017 · 32 comments · Fixed by #383, #384 or #390
Milestone

Comments

@ownmaster
Copy link

Hi,

I can't install posh-git via choco or install-package/install-module.
When I install using install-package or install-module posh-git gets installed (I can see it in 'modules' folder), but import-module posh-git doesn't bring it.
If I install using choco setup fails:

Get-BinRoot is going to be deprecated in v1 and removed in v2. It has been replaced with Get-ToolsLocation (starting with v0.9.10), however many packages no longer require a special separate directory since package folders no longer have versions on them. Some do though and should continue to use Get-ToolsLocation.
Extracting C:\Users\username\AppData\Local\Temp\chocolatey\poshgit\0.6.1.20160330\dahlbyk-posh-git-v0.6.1-224-g5ada37f.zip to C:\tools\poshgit...                                                                                                                                      
C:\tools\poshgit
ERROR: Cannot bind argument to parameter 'Path' because it is an empty string.                                                              
The install of poshgit was NOT successful.                                                                                                  
Error while running 'C:\ProgramData\chocolatey\lib\poshgit\tools\chocolateyInstall.ps1'.                                                    

I only managed to install it by first installing PsGet and then running install-module, then manually addding import-module to profile. But in this case I've got version 0.7.0.

System info:

posh-git version: 0.6.1, PSVersion: 5.1.14393.693, git version 2.10.1.windows.1, OS: Microsoft Windows NT 10.0.14393.0
@rkeithhill
Copy link
Collaborator

rkeithhill commented Jan 29, 2017

Since you are on PS 5.1, you shouldn't need to use Chocolatey. You say you first installed PSGet, but you shouldn't have to do that. PS v5 and higher come with two modules: PackageManagement (manager of pkg managers) and PowerShellGet. The latter supersedes the need for the older, community created PSGet.

If posh-git did get installed into $Home\Documents\WindowsPowerShell\Modules\posh-git\0.6.1.20160330, let's make sure it installed correctly. First, import from that location e.g.:

Import-Module $Home\Documents\WindowsPowerShell\Modules\posh-git\0.6.1.20160330\posh-git.psd1

Also check for the existence of the following file:

Get-Item -Force $Home\Documents\WindowsPowerShell\Modules\posh-git\0.6.1.20160330\PSGetModuleInfo.xml

If that file doesn't exist, then you probably installed with the old PSGet. If it exists, then it was installed with PowerShellGet - which means you can use Update-Module posh-git to update to newer versions.

OK, so if the above import worked but "Import-Module posh-git" does not work, it means your PSModulePath environment variable is borked. Output its value with $Env:PSModulePath. It should look like this:

C:\Users\Keith\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files\Microsoft Message Analyzer\PowerShell\

Note that it is the existence of C:\Users\<username>\Documents\WindowsPowerShell\Modules that allows PowerShell to load modules from your Modules directory. If that doesn't exist, then go to the System Properties and edit the PSModulePath environment variable to add this path.

RE version 0.7.0, you have a pre-release of 0.7.0. When 0.7.0 releases (shortly - hopefully) you will need to remove that version and then install the released version from the PSGallery.

@canpolat
Copy link

canpolat commented Jan 30, 2017

Hi,

I was having the exact same problem when I found out this issue report (I didn't know not to use chocolatey for installation). Then I followed your readme.md.

Install-Module -Name posh-git seemed to have succeeded. Get-Module -Name posh-git returns the following:

ModuleType Version    Name     ExportedCommands
---------- -------    ----     ----------------
Script     0.6.1.2... posh-git {Add-SshKey, Enable-GitColors, Get-AliasPattern, Get-GitDirectory...}

The Import-Module posh-git command does not output anything (I'm assuming this is a good thing) but the command prompt does not change.

My PSModulePath includes C:\Users\<username>\Documents\WindowsPowerShell\Modules.

PSversion:

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      14393  693

git version: 2.11.0.windows.3

OSVersion:

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      14393  0

PS: In your readme, you mention a command Add-PoshGitToProfile. posh-git does not seem to export it. Also, $GitPromptSettings does not contain DefaultPromptSuffix, it has the following:

LocalWorkingStatusForegroundColor         : Red
AfterStashBackgroundColor                 : DarkMagenta
WorkingForegroundBrightColor              : Red
RepositoriesInWhichToDisableFileStatus    : {}
IndexForegroundColor                      : Green
BranchForegroundColor                     : Cyan
BeforeStashForegroundColor                : Red
EnablePromptStatus                        : True
AfterBackgroundColor                      : DarkMagenta
LocalStagedStatusSymbol                   : ~
BeforeIndexBackgroundColor                : DarkMagenta
AfterText                                 : ]
BeforeForegroundColor                     : Yellow
LocalWorkingStatusSymbol                  : !
BranchAheadStatusSymbol                   : ↑
LocalDefaultStatusSymbol                  :
IndexForegroundBrightColor                : Green
WorkingForegroundColor                    : Red
LocalStagedStatusForegroundColor          : Cyan
ShowStatusWhenZero                        : True
BranchIdenticalStatusToBackgroundColor    : DarkMagenta
BeforeIndexForegroundColor                : Green
BranchIdenticalStatusToSymbol             : ≡
BranchBehindAndAheadStatusForegroundColor : Yellow
LocalDefaultStatusForegroundColor         : Green
DescribeStyle                             :
BranchBackgroundColor                     : DarkMagenta
LocalStagedStatusBackgroundColor          : DarkMagenta
AfterStashText                            : )
BeforeBackgroundColor                     : DarkMagenta
BeforeIndexForegroundBrightColor          : Green
EnableStashStatus                         : False
Debug                                     : False
LocalWorkingStatusForegroundBrightColor   : Red
LocalWorkingStatusBackgroundColor         : DarkMagenta
IndexBackgroundColor                      : DarkMagenta
DelimText                                 :  |
BranchBehindAndAheadStatusSymbol          : ↕
WorkingBackgroundColor                    : DarkMagenta
EnableWindowTitle                         : posh~git ~
DefaultForegroundColor                    : DarkYellow
BranchNameLimit                           : 0
AfterForegroundColor                      : Yellow
DelimBackgroundColor                      : DarkMagenta
BranchBehindStatusForegroundColor         : Red
AfterStashForegroundColor                 : Red
LocalDefaultStatusForegroundBrightColor   : Green
LocalDefaultStatusBackgroundColor         : DarkMagenta
StashForegroundColor                      : Red
DelimForegroundColor                      : Yellow
TruncatedBranchSuffix                     : ...
BeforeStashBackgroundColor                : DarkMagenta
StashBackgroundColor                      : DarkMagenta
BranchAheadStatusForegroundColor          : Green
BranchUntrackedSymbol                     :
BranchBehindStatusBackgroundColor         : DarkMagenta
BranchAheadStatusBackgroundColor          : DarkMagenta
AutoRefreshIndex                          : True
BeforeText                                :  [
BranchBehindStatusSymbol                  : ↓
BranchBehindAndAheadStatusBackgroundColor : DarkMagenta
BeforeIndexText                           :
EnableFileStatus                          : True
BeforeStashText                           :  (
BranchIdenticalStatusToForegroundColor    : Cyan

@rkeithhill
Copy link
Collaborator

rkeithhill commented Jan 30, 2017

We haven't release 0.7.0 to the PSGallery yet. You won't see the prompt change on import until 0.7.0 releases. Hopefully in the coming week (or two). In the mean time execute notepad $profile.CurrentUserAllHosts and add the following to it:

function prompt {
    $origLastExitCode = $LASTEXITCODE
    Write-Host $ExecutionContext.SessionState.Path.CurrentLocation -NoNewline
    Write-VcsStatus
    $LASTEXITCODE = $origLastExitCode
    "$('>' * ($nestedPromptLevel + 1)) "
}

Import-Module posh-git

Once 0.7.0 comes out and you run Update-Module posh-git, you will be able to remove the prompt function from your profile (but leave in the import command).

@canpolat
Copy link

@rkeithhill Thank you for the prompt response. It works after applying your suggestion.

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 30, 2017

Back to the original issue: I believe the removal of the call to install.ps1 in c2cb856 was premature; a clean install over in #358 doesn't work either. 😦

@rkeithhill
Copy link
Collaborator

@dahlbyk :-( indeed. What can I help with (later tonight)?

@canpolat
Copy link

Sorry for hijacking the thread. In my setup, the C:\ProgramData\chocolatey\lib\poshgit directory did not exist when I got the Error while running 'C:\ProgramData\chocolatey\lib\poshgit\tools\chocolateyInstall.ps1'. error. Not sure if that helps with anything, though :)

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 30, 2017

@canpolat please confirm your Chocolatey version?

All: #383 should fix at least part of the problem. Unfortunately I need to merge to confirm. (Also something about our Chocolatey package that will be fixed by #358.)

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 30, 2017

@ownmaster @canpolat I just tested a clean choco install poshgit (choco v0.9.9.6) without issue.

C:\ProgramData\chocolatey\lib\poshgit\poshgitInstall.zip.txt contains:

C:\tools\poshgit\dahlbyk-posh-git-3959aa1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\.vscode
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\chocolatey
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\.editorconfig
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\.gitattributes
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\.gitignore
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\appveyor.yml
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\CHANGELOG.md
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\install.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\ISSUE_TEMPLATE.md
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\LICENSE.txt
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\profile.example.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\PSScriptAnalyzerSettings.psd1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\README.md
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\.vscode\launch.json
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\.vscode\settings.json
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\.vscode\tasks.json
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\chocolatey\tests
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\chocolatey\tools
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\chocolatey\poshgit.nuspec
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\chocolatey\tests\dahlbyk-posh-git-60be436.zip
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\chocolatey\tests\InstallChocolatey.Tests.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\chocolatey\tools\chocolateyInstall.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\en-US
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\CheckVersion.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\GitPrompt.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\GitTabExpansion.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\GitUtils.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\posh-git.psd1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\posh-git.psm1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\TortoiseGit.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\Utils.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\src\en-US\about_posh-git.help.txt
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test\Get-GitBranch.Tests.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test\Get-GitDirectory.Tests.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test\Get-GitStatus.Tests.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test\git-help.txt
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test\ModuleManifest.Tests.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test\Shared.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test\Ssh.Tests.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test\testDebugHarness.ps1
C:\tools\poshgit\dahlbyk-posh-git-3959aa1\test\Utils.Tests.ps1

@canpolat
Copy link

@dahlbyk I'm on a different PC now but I'm pretty sure my chocolatey version was 0.10.3.

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 30, 2017

If anyone cares to dig into this, I pushed a preview release of 0.7 and Chocolatey package verification failed with this same error: #358 (comment).

@dahlbyk dahlbyk reopened this Jan 30, 2017
@dahlbyk
Copy link
Owner

dahlbyk commented Jan 30, 2017

I haven't had a chance to dig in, but the full error trace is available here: https://gist.github.com/choco-bot/8fd09f341ed80aa5cf6ae01f39b49763

Here's the specific error:

2017-01-30 18:46:34,436 [ERROR] - ERROR: Cannot bind argument to parameter 'Path' because it is an empty string.
 at Add-PoshGitToProfile, C:\tools\poshgit\dahlbyk-posh-git-9f6b256\src\Utils.ps1: line 98
at <ScriptBlock>, C:\tools\poshgit\dahlbyk-posh-git-9f6b256\install.ps1: line 6
at <ScriptBlock>, C:\ProgramData\chocolatey\lib\poshgit\tools\chocolateyInstall.ps1: line 42
at <ScriptBlock>, C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1: line 48
at <ScriptBlock>, <No file>: line 1

@ownmaster
Copy link
Author

I did not expect so many posts here, but will try to make everything clear :)

I never said I first installed PsGet. If talking about order:

  1. I tried choco (I know I don't have to use choco, I just like to use it)
  2. Tried install-module
  3. Tried install-package
  4. And only after all that failed I installed PsGet, and then installed posh-git using PsGet

I know what PsGet is, but that was the only way that worked in my situation.
The system before all described actions was brand new (it is actually brand new laptop, with preinstalled Windows 10 Home 64bit).

Now, I removed working posh-git and PsGet and tried again install-module. It is installed into c:\Program Files\WindowsPowerShell\Modules\posh-git\0.6.1.20160330\. PSGetModuleInfo.xml is there. $env:PSModulePath is OK - C:\Users\username\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules.
But import-module doesn't give any result.
Below is output of Import-Module posh-git -Verbose:

VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\posh-git\0.6.1.20160330\posh-git.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module posh-git.                                           
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\posh-git\0.6.1.20160330\posh-git.psm1'.
VERBOSE: Importing function 'Add-SshKey'.                                                                            
VERBOSE: Importing function 'Enable-GitColors'.                                                                      
VERBOSE: Importing function 'Get-AliasPattern'.                                                                      
VERBOSE: Importing function 'Get-GitDirectory'.                                                                      
VERBOSE: Importing function 'Get-GitStatus'.                                                                         
VERBOSE: Importing function 'Get-SshAgent'.                                                                          
VERBOSE: Importing function 'Get-SshPath'.                                                                           
VERBOSE: Importing function 'Invoke-NullCoalescing'.                                                                 
VERBOSE: Importing function 'Start-SshAgent'.                                                                        
VERBOSE: Importing function 'Stop-SshAgent'.                                                                         
VERBOSE: Importing function 'TabExpansion'.                                                                          
VERBOSE: Importing function 'tgit'.                                                                                  
VERBOSE: Importing function 'Update-AllBranches'.                                                                    
VERBOSE: Importing function 'Write-GitStatus'.                                                                       
VERBOSE: Importing function 'Write-Prompt'.                                                                          
VERBOSE: Importing alias '??'.                                                                                       

@canpolat
Copy link

@ownmaster did you try the suggestion at: #381 (comment)

I had the same problem and following @rkeithhill's comment solved it for me.

@rkeithhill
Copy link
Collaborator

@ownmaster

But import-module doesn't give any result.

Import won't give any result if the module imports without problems. That's just how PowerShellGet\Import-Module works. However, once 0.7.0 releases, importing posh-git should change the default prompt function to display Git status summary info when in a Git repo. However, if you already have a prompt function defined in your PowerShell profile, posh-git will not modify the prompt.

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 30, 2017

New error! 😡 Suppose I should upgrade Chocolatey so I can reproduce locally.

https://gist.github.com/choco-bot/a36989a10a30e911ac05694c5c6f5136

2017-01-30 20:54:30,783 [ERROR] - ERROR: Cannot bind argument to parameter 'LiteralPath' because it is null.
 at Add-PoshGitToProfile, C:\tools\poshgit\dahlbyk-posh-git-9d559c4\src\Utils.ps1: line 129
at <ScriptBlock>, C:\tools\poshgit\dahlbyk-posh-git-9d559c4\install.ps1: line 6
at <ScriptBlock>, C:\ProgramData\chocolatey\lib\poshgit\tools\chocolateyInstall.ps1: line 42
at <ScriptBlock>, C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1: line 48
at <ScriptBlock>, <No file>: line 1

@dahlbyk dahlbyk reopened this Jan 30, 2017
@dahlbyk dahlbyk added this to the v0.7 milestone Jan 30, 2017
@ownmaster
Copy link
Author

@rkeithhill

However, if you already have a prompt function defined in your PowerShell profile, posh-git will not modify the prompt.

Nothing was defined in my profile. I supposed that profile should be modified automatically during install. Copied and modified profile posh-git configuration from another PC, now I have modified prompt.

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 30, 2017

I supposed that profile should be modified automatically during install.

It used to (see #383). Still trying to get back to the point where that works again. ☹️

@ownmaster
Copy link
Author

#383 title says about choco. What about native PowerShell installation methods, did they also break at some point?

@rkeithhill
Copy link
Collaborator

@ownmaster The native PowerShell installation method has not been updated to 0.7.0. It is still installing 0.6.1.20160330 (released last year).

Once a new user has installed 0.7.0 via the PowerShellGet\Install-Module (or Update-Module) command, they only need to run Add-PoshGitToProfile to have the Import-Module posh-git command to their profile script. However, since you've already done this (manually), you won't need to do anything else once you've updated to 0.7.0.

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 31, 2017

🆗 I think I have everything cleared up. If anyone here still wants to use Chocolatey, try this:

choco install poshgit --version=0.7.0-pre4

@bforrest
Copy link

@dahlbyk using choco install poshgit --version=0.7.0-pre4 worked like a charm.

I was previously getting the "Cannot bind arguement to parameter 'LiteralPath'... error.
poshgit

Thank you.

@ownmaster
Copy link
Author

@dahlbyk how to load posh-git after 0.7.0-pre4 installation via choco?

@rkeithhill
Copy link
Collaborator

rkeithhill commented Jan 31, 2017

Executing Import-Module posh-git or restarting PowerShell doesn't load the module? Or maybe you have to supply the path to Import-Module e.g. Import-Module C:\tools\poshgit\posh-git.psd1. Or maybe that path should have the version in it?

@ownmaster
Copy link
Author

Yeah, forgot that module is installed into location which is not in PowerShell paths list. Added it manually.

BTW, when 0.7.0 is initially loaded it shows prompt as ~> but after any directory change it becomes regular c:\folder. Is it by design?

@rkeithhill
Copy link
Collaborator

rkeithhill commented Feb 1, 2017

Yes and that is something that is currently under discussion at #386. Basically, since the posh-git provided prompt is a single line - with a lot of info to potentially display - we substitute ~ for your home directory e.g. C:\Users\ownmaster. If you are not in or under your home dir, you will see a full path. We are likely to add a $GitPromptSettings property to allow you to control that. At the moment, the debate is over what the default should be (to abbreviate or not).

@rkeithhill
Copy link
Collaborator

@ownmaster Do you consider this issue fixed - considering you can only install the latest pre-release from Chocolatey ATM?

@canpolat
Copy link

canpolat commented Feb 1, 2017

I did not have access to that PC yesterday. Today, I tryied the 0.7.0-pre4 version and the installation wen thru. Thank you for the quick response.

@dahlbyk
Copy link
Owner

dahlbyk commented Feb 1, 2017

0.7.0 is Coming Soon, but I went ahead and pulled the important bits from #358 into master anyway to fix non-prerelease installs. Thanks, again, for the bug report @ownmaster!

@ownmaster
Copy link
Author

@rkeithhill I guess yes, it is fixed - now I can install. :) I hope in 0.7.? release it will be added to profile automagically after setup.

@rkeithhill
Copy link
Collaborator

it will be added to profile automagically after setup.

If using Chocolatey, yes. But no if using PowerShellGet\Install-Module. The latter just downloads, unzips and copies the bits to the specified Modules folder - nothing more.

@dahlbyk
Copy link
Owner

dahlbyk commented Feb 2, 2017

it will be added to profile automagically after setup.

If using Chocolatey, yes. But no if using PowerShellGet\Install-Module. The latter just downloads, unzips and copies the bits to the specified Modules folder - nothing more.

We started down the automagical path with #361, but couldn't reliably decide if we should add to profile or not. We ended up with the deterministic Add-PoshGitToProfile instead.

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