Running Add-PoshGitToPrompt (via install.ps1 or directly) is correctly finding my posh-git clone in $PSModulePath (and inserting Import-Module posh-git instead of an absolute path), but that Import-Module posh-git call fails with:
```
import-module : The specified module 'posh-git' was not loaded because no valid module file was found in any module directory.
At line:1 char:1

Any ideas to troubleshoot, @rkeithhill?
I think Import-Module is looking for a particular directory scheme <module-name>[module-version] under each path in PSModulePath. Another reason why I rarely mess with PSModulePath. :-) This is in my profile:
Import-Module ~\GitHub\dahlbyk\Posh-Git\src\posh-git.psd1
If you remove C:\Dev\OSS\posh-git\src from PSModulePath and remove the import command from your profile, then impo from C:\Dev\OSS\posh-git\src and then run Add-PoshGitToProfile, it should use the full path.
Yep, that's it. Moving the module into src/ means a normal posh-git clone no longer matches the expected pattern. Few options:
src/* to src/posh-git/*$PSModulePath check if (SplitPath $ModuleBasePath -Leaf) -eq 'src'Get-Module posh-git -ListAvailable sanity check after a $PSModulePath matchLeaning toward 2锔忊儯
I think we should leave in the PSModulePath to handle the normal install-module install. Before that check we could check for current dir of src and/or ../.git and then import by path. That would cover the git clone case.
Hello,
I have PS version 2. Hence, am using Chocolatey to install posh-git. Any ideas how to go about it?
Sorry for being a noob.
Error:
The "=" operator is missing after a named argument.
ERROR: The module to process 'posh-git.psm1', listed in field 'ModuleToProcess' of module manifest 'C:\tools\poshgit\dah
lbyk-posh-git-a4faccd\src\posh-git.psd1' was not processed because no valid module was found in any module directory.

@marc88 try renaming the C:\tools\poshgit\dahlbyk-posh-git-a4faccd\src folder from src to posh-git and update your $PROFILE accordingly. In other cases we've seen PowerShell be picky about loading modules if the folder name doesn't match the module name. (Which is really silly behavior, I might add.)
@dahlbyk : Thank you for the solution!
It worked indeed. But, I tried upgrading powershell to v3.0 and I found Import-Module added the module base directly to my profile. That's when I realised what was actually wrong :)
@dahlbyk Followed those steps and worked for me too. Cheers.

Where I'm going wrong I'm not able to fix this one, need some help
Does your home dir name really have a space in it? I could see how that might cause PS to have issues loading modules. What do you get when you execute $env:PSModulePath. Also, try to specify the full path to the module like so:
import-module "$HOME\Documents\WindowsPowerShell\Modules\posh-git\<version-number>\posh-git.psm1"
@dahlbyk Hi, what's the outcome of this issue? I've set up posh-git today and found out this issue still persists, at least for choco.
Btw, the last suggestion works too, I've used it myself as it's really the only way to make importing it future-proof.
@Jan-Karasinski What are the contents of your profile - gc $profile and gc $profile.CurrentUserAllHosts? I just tested a choco install of posh-git in a Windows Sandbox instance and got this for $profile contents ($profile.CurrentUserAllHosts didn't exist):
Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-9bda399\src\posh-git.psd1'
And posh-git imported successfully.
@rkeithhill It was empty and I had to modify it manually, with the full path. Also, my PowerShell env was fresh, I was using it just to execute simple commands that were not requiring any kind of modifications/privileges.
@Jan-Karasinski So you up and running with posh-git?
@rkeithhill Yep, it works like a charm.
Most helpful comment
Does your home dir name really have a space in it? I could see how that might cause PS to have issues loading modules. What do you get when you execute
$env:PSModulePath. Also, try to specify the full path to the module like so: