Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git for Windows doesn't know %USERPROFILE%

I have the same issue like Git for Windows doesn't execute my .bashrc file and tried to make the same steps. But my Git Bash (2.5.0, 64bit on Windows 7, 64bit) doesn't know my %USERPROFILE%.

pitgrap@xxx MINGW64 /
$ pwd
/

pitgrap@xxx MINGW64 /
$ cd ~
bash: cd: /%USERPROFILE%: No such file or directory

If I run Git Bash as Administror, it works. :( But I don't want to run it everytime as Administrator. Any ideas?

like image 595
pitgrap Avatar asked Aug 25 '15 12:08

pitgrap


2 Answers

The new Git-for-Windows is using a %HOME% enviroment variable. It was set on my machine to HOME=%USERPROFILE%. You can't use another variable here. Remove it or change it to a real path.

See also https://github.com/git-for-windows/git/issues/313

like image 94
pitgrap Avatar answered Sep 20 '22 14:09

pitgrap


This just has to do with how each of those different languages handle variable expansion.

cmdC:\> echo %USERPROFILE%
bash: $ echo $USERPROFILE
ps:     PS> echo $env:USERPROFILE

In windows cmd prompt, variables should be surrounded by % on either side
Whereas Bash and PowerShell indicate a variables by prefixing with a $.

Git Bash gets all existing Windows environment variables at startup, while powershell tries to limit polluting the global namespace by including them under the $env object

Shell Comparison

If you want to confirm the shell has access to the environment variable, you can list all variables:

cmd (docs)C:\> SET
bash (docs): $ printenv
ps (docs):     PS> Get-ChildItem env:

like image 45
KyleMit Avatar answered Sep 19 '22 14:09

KyleMit