Posh-git: git config doesn't recognize U:\ as the user directory in PowerShell

Created on 18 Jun 2018  Â·  5Comments  Â·  Source: dahlbyk/posh-git

System Details

  • posh-git version/path: 0.7.3 C:Program FilesWindowsPowerShellModulesposh-git0.7.3
  • PowerShell version: 5.1.17134.112
  • git version 2.17.1.windows.2
  • OS: Microsoft Windows NT 10.0.17134.0

Issue Description

I am experiencing a problem with git config in PowerShell, which I'm assuming is the case since it doesn't recognize U: as the user directory. Whenever I query my identity with something like git config user.email it returns nothing, while doing the same in git-bash.exe shell works as intended. This problem happens whether I use --global or omit it for local config.

Even my config within my local .git folder has the proper email listed under [user] but it still generates some fake email using my domain login. Again, I have no problems when I use git-bash.exe

Most helpful comment

Because of roaming profiles and VPN connections I had a similar situation, that the U: drive as my home folder was not available when I had to connect via VPN (U-Drive was not connected).
In these cases, Git-Bash chose the .gitconfig from the "local home" (c:\users\<account>). But posh-git was not able to do the same. ($Home pointed to c:\users\<account> but $Env:Home pointed to U:\, which was not connected and therefore not available). Without having the .gitconfig none of my aliases were available.
To work-around this, I did a $Env:Home = $Home. After this all my aliases were back.

All 5 comments

My first guess is that your HOME environment variable isn't set. What do you get for $HOME or $Env:HOME?

What do you get from git config --show-origin --name-only --list? (No values will be included, so safe to share.)

I tested all this on my home computers and they all worked fine. The problem seems to only occur on my work computer so it may be an issue with how my work computer's credentials/domain are setup (outsourced IT dept, not sure what was all done). If this seems to be out of scope of posh-git feel free to close it. I've included results from the variables below.

$HOME returns: my actual user directory (C:Usersjknobler)
$Env:HOME returns: U:

and git config --show-origin --name-only --list returns

file:"C:\\ProgramData/Git/config"       core.symlinks
file:"C:\\ProgramData/Git/config"       core.autocrlf
file:"C:\\ProgramData/Git/config"       core.fscache
file:"C:\\ProgramData/Git/config"       color.diff
file:"C:\\ProgramData/Git/config"       color.status
file:"C:\\ProgramData/Git/config"       color.branch
file:"C:\\ProgramData/Git/config"       color.interactive
file:"C:\\ProgramData/Git/config"       help.format
file:"C:\\ProgramData/Git/config"       rebase.autosquash
file:C:/Program Files/Git/mingw64/etc/gitconfig http.sslcainfo
file:C:/Program Files/Git/mingw64/etc/gitconfig http.sslbackend
file:C:/Program Files/Git/mingw64/etc/gitconfig diff.astextplain.textconv
file:C:/Program Files/Git/mingw64/etc/gitconfig filter.lfs.clean
file:C:/Program Files/Git/mingw64/etc/gitconfig filter.lfs.smudge
file:C:/Program Files/Git/mingw64/etc/gitconfig filter.lfs.process
file:C:/Program Files/Git/mingw64/etc/gitconfig filter.lfs.required
file:C:/Program Files/Git/mingw64/etc/gitconfig credential.helper
file:C:/Program Files/Git/mingw64/etc/gitconfig core.editor
file:.git/config        core.repositoryformatversion
file:.git/config        core.filemode
file:.git/config        core.bare
file:.git/config        core.logallrefupdates
file:.git/config        core.symlinks
file:.git/config        core.ignorecase
file:.git/config        remote.origin.url
file:.git/config        remote.origin.fetch
file:.git/config        branch.master.remote
file:.git/config        branch.master.merge
file:.git/config        gui.wmstate
file:.git/config        gui.geometry
file:.git/config        submodule.SlotFramework/Engines/HarmonyEngine.url
file:.git/config        submodule.SlotFramework/Engines/HarmonyEngine.active
file:.git/config        status.submodulesummary
file:.git/config        user.email
file:.git/config        user.name

While I'm still unable to reach the global config:

D:\Soft\lgdev\SlotFramework\Engines [master ↑2]> git config --global user.name "Jason Knobler"
error: could not lock config file U://.gitconfig: No such file or directory

I seem to have been able to finally have my local repo's config take effect once I did a git commit --amend --reset-author. This is workable for me, assuming it keeps working. I don't want to waste anymore of your time since the problem is likely with my work computer, so feel free to close the issue unless you want to respond with more info.

I'm going to go ahead and close this, since it doesn't seem to be specific any posh-git functionality...

That being said, this code is probably relevant. Since it's working in Git Bash, what does echo $HOME show there? Does the problem go away if you set $Env:HOME = "$Env:USERPROFILE" (or otherwise set $Env:HOME to C:\Users\jknobler)?

Because of roaming profiles and VPN connections I had a similar situation, that the U: drive as my home folder was not available when I had to connect via VPN (U-Drive was not connected).
In these cases, Git-Bash chose the .gitconfig from the "local home" (c:\users\<account>). But posh-git was not able to do the same. ($Home pointed to c:\users\<account> but $Env:Home pointed to U:\, which was not connected and therefore not available). Without having the .gitconfig none of my aliases were available.
To work-around this, I did a $Env:Home = $Home. After this all my aliases were back.

Was this page helpful?
0 / 5 - 0 ratings