{"thread":{"id":"41434","subject":"Windows git bash - child processes see system PATH environment variable instead of user...","startedAt":"2016-02-17T21:31:30Z","lastAt":"2016-02-19T11:33:53Z","messageCount":4,"participants":["Edward Marshall","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"278510","messageId":"CAN2vHUFYqKDDEJpGtxJ9aD+8abe-krnHBy7cm1tMm0+bh5ykBQ@mail.gmail.com","threadId":"41434","inReplyTo":null,"subject":"Windows git bash - child processes see system PATH environment variable instead of user...","fromName":"Edward Marshall","fromEmail":"marshallx7a@gmail.com","sentAt":"2016-02-17T21:31:30Z","receivedAt":"2016-02-17T21:31:30Z","isPatch":false,"sender":{"key":"marshallx7a@gmail.com","avatar":null},"body":"This happens on my Windows 7 Home Premium x64 SP1 Desktop, but not on\nmy Windows 10 Pro x64 laptop.\n\nEverything used to work fine until I updated my Desktop to the latest\nversion of Git (the laptop has the same version but was a totally\nclean install as it is a new laptop)\n\nEdward@Edward-PC MINGW64 /f/Work\n$ echo $PATH\n...(USER PATH)...\n\nEdward@Edward-PC MINGW64 /f/Work\n$ cmd\nMicrosoft Windows [Version 6.1.7601]\nCopyright (c) 2009 Microsoft Corporation. All rights reserved.\n\nF:\\Work>echo %PATH%\necho %PATH%\n...(SYSTEM PATH)...\n\nThe same is true of any child process (e.g. node.js) - they all see\nSYSTEM PATH now instead of USER PATH.\nI have tried clean reinstalling git.\nI have tried both the 64-bit and 32-bit versions of git.\n\nUsed Process Explorer to investigate the environment of the processes\non the 2 machines. The only significant difference I can see is the\nPATH variable in cmd.exe.\n\nIf I double-click bash.exe (instead of the shortcut to git-bash.exe)\nthen the user PATH is seen by child processes.\nDouble clicking git-bash.exe, still has the problem.\nRunning bash -l from a cmd window, has the problem.\n\nRun bash.exe, then\nsh\necho $PATH\n// Shows user path\ncmd\necho %PATH%\n// Now shows system path\nSo bash saw user path, sh saw user path but then cmd was passed the\nsystem path?!\n\nRun bash.exe followed by cmd, cmd, cmd, etc - cmd always sees user path.\nSo bash -l and sh both see user path but then only forward system path\nto child processes...\n\nsh definitely used to work as well as the git bash shortcut (I know\nbecause I run git bash > grunt > sh and that now sees the\nwrong/incomplete path when before it was working fine)\n\nI have spent most of this frustrating day trying to figure out what is\ngoing wrong but do not have a clue.\n\nI have no .bashrc or .bash_profile files on either system (no idea\nwhat these are for but a colleague was trying to help diagnose the\nproblem - they ultimately came up empty).\nAs far as I can tell the 2 systems are set up exactly the same (apart\nfrom the different Windows versions of course).\nPath length is not an issue as the (working) laptop has a huge path\nwhereas the (not working) desktop has less than 500 characters.\n\nUnfortunately I don't know what version of git I had before, and older\nversions aren't offered for download so I can't trial and error.\nReally wishing I hadn't upgraded!\n\nAny assistance would be much appreciated as I am totally pulling my\nhair out now.\n\nMany thanks and kind regards,\n\nEdward Marshall\n"},{"id":"278635","messageId":"alpine.DEB.1.00.1602191154190.20796@bonsai2","threadId":"41434","inReplyTo":"CAN2vHUFYqKDDEJpGtxJ9aD+8abe-krnHBy7cm1tMm0+bh5ykBQ@mail.gmail.com","subject":"Re: Windows git bash - child processes see system PATH environment variable instead of user...","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-19T11:08:48Z","receivedAt":"2016-02-19T11:08:48Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Edward,\n\nOn Wed, 17 Feb 2016, Edward Marshall wrote:\n\n> Edward@Edward-PC MINGW64 /f/Work\n> $ echo $PATH\n> ...(USER PATH)...\n\nI presume this is Git for Windows 2.7.1(2), installed via the default\ninstaller?\n\nAnd I also assume that you run this in Git Bash?\n\nCan you test whether this also happens in the PortableGit from\nhttps://github.com/git-for-windows/git/releases/latest? (These are\nself-extracting .7z archives, just install them somewhere else than your\ncurrent installation, it won't touch your Start Menu or desktop icons.)\n\nThe Git Bash is available in the portable installation as git-bash.exe in\nthe top-leve directory.\n\n> Edward@Edward-PC MINGW64 /f/Work\n> $ cmd\n> Microsoft Windows [Version 6.1.7601]\n> Copyright (c) 2009 Microsoft Corporation. All rights reserved.\n> \n> F:\\Work>echo %PATH%\n> echo %PATH%\n> ...(SYSTEM PATH)...\n> \n> The same is true of any child process (e.g. node.js) - they all see\n> SYSTEM PATH now instead of USER PATH.\n\nAre you sure that it is \"instead of\"? AFAICT both Git CMD and Git Bash\nshould have the full PATH, i.e. both system and user PATH concatenated.\n\n> Running bash -l from a cmd window, has the problem.\n\nNow, this is interesting. Maybe something funky does happen in some\nstrange place in the Bash profile.\n\nIf you can reproduce this with the portable Git, it would be good to\ninsert the line \"set -x\" at the top of %PORTABLEGIT%\\etc\\profile\n(that is the correct file name IIRC, it could also be bash.bash_profile,\nbut I think the latter is included by the former). Then start bash -l\nagain, and see whether you can find the place where it sets the PATH.\n\nTo be certain, I would also recommend outputting the PATH with which Bash\nstarts, either by inserting a line \"echo $PATH\" at the top of the profile\nfile, or by starting bash without -l option.\n\n> I have no .bashrc or .bash_profile files on either system (no idea\n> what these are for but a colleague was trying to help diagnose the\n> problem - they ultimately came up empty).\n\nCould be a .profile, too, maybe.\n\n> Unfortunately I don't know what version of git I had before, and older\n> versions aren't offered for download so I can't trial and error.\n\nOlder versions are still available (we did not remove any) from\nhttps://github.com/git-for-windows/git/releases (and if you look for the\n1.x series that was using a completely different Bash/MSYS:\nhttps://github.com/msysgit/msysgit/releases).\n\nCiao,\nJohannes\n"},{"id":"278636","messageId":"CAN2vHUHhqVn8uXaUTdeU5mKuRLQ1084wJu27k4nMJgywOjdOdA@mail.gmail.com","threadId":"41434","inReplyTo":"alpine.DEB.1.00.1602191154190.20796@bonsai2","subject":"Re: Windows git bash - child processes see system PATH environment variable instead of user...","fromName":"Edward Marshall","fromEmail":"marshallx7a@gmail.com","sentAt":"2016-02-19T11:15:18Z","receivedAt":"2016-02-19T11:15:18Z","isPatch":false,"sender":{"key":"marshallx7a@gmail.com","avatar":null},"body":"Hey, thanks for getting back to me. I subseuqently found the\ngit-for-windows issues tracker on github so have posted an updated\nversion of this there - not sure where is the best place for issues.\n\nI have also found that the cause was having\n%VPROJECT%..\\bin\ninside my user PATH\nbut no VPROJECT environment variable.\nRemoving the path or adding the missing env var fixes the problem.\nThis suggests that something is failing to concatenate user PATH to\nsystem PATH when it can't expand the non-existent environment\nvariable.\n\nfwiw, I don't have a .profile file either.\n\nHopefully you can replicate the problem with the above info, but\nplease let me know if you still want me to run anything or if there is\nanything else I can do to help.\n\nKind regards,\n\nEdward Marshall\n\n\nOn 19 February 2016 at 11:08, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi Edward,\n>\n> On Wed, 17 Feb 2016, Edward Marshall wrote:\n>\n>> Edward@Edward-PC MINGW64 /f/Work\n>> $ echo $PATH\n>> ...(USER PATH)...\n>\n> I presume this is Git for Windows 2.7.1(2), installed via the default\n> installer?\n>\n> And I also assume that you run this in Git Bash?\n>\n> Can you test whether this also happens in the PortableGit from\n> https://github.com/git-for-windows/git/releases/latest? (These are\n> self-extracting .7z archives, just install them somewhere else than your\n> current installation, it won't touch your Start Menu or desktop icons.)\n>\n> The Git Bash is available in the portable installation as git-bash.exe in\n> the top-leve directory.\n>\n>> Edward@Edward-PC MINGW64 /f/Work\n>> $ cmd\n>> Microsoft Windows [Version 6.1.7601]\n>> Copyright (c) 2009 Microsoft Corporation. All rights reserved.\n>>\n>> F:\\Work>echo %PATH%\n>> echo %PATH%\n>> ...(SYSTEM PATH)...\n>>\n>> The same is true of any child process (e.g. node.js) - they all see\n>> SYSTEM PATH now instead of USER PATH.\n>\n> Are you sure that it is \"instead of\"? AFAICT both Git CMD and Git Bash\n> should have the full PATH, i.e. both system and user PATH concatenated.\n>\n>> Running bash -l from a cmd window, has the problem.\n>\n> Now, this is interesting. Maybe something funky does happen in some\n> strange place in the Bash profile.\n>\n> If you can reproduce this with the portable Git, it would be good to\n> insert the line \"set -x\" at the top of %PORTABLEGIT%\\etc\\profile\n> (that is the correct file name IIRC, it could also be bash.bash_profile,\n> but I think the latter is included by the former). Then start bash -l\n> again, and see whether you can find the place where it sets the PATH.\n>\n> To be certain, I would also recommend outputting the PATH with which Bash\n> starts, either by inserting a line \"echo $PATH\" at the top of the profile\n> file, or by starting bash without -l option.\n>\n>> I have no .bashrc or .bash_profile files on either system (no idea\n>> what these are for but a colleague was trying to help diagnose the\n>> problem - they ultimately came up empty).\n>\n> Could be a .profile, too, maybe.\n>\n>> Unfortunately I don't know what version of git I had before, and older\n>> versions aren't offered for download so I can't trial and error.\n>\n> Older versions are still available (we did not remove any) from\n> https://github.com/git-for-windows/git/releases (and if you look for the\n> 1.x series that was using a completely different Bash/MSYS:\n> https://github.com/msysgit/msysgit/releases).\n>\n> Ciao,\n> Johannes\n"},{"id":"278659","messageId":"alpine.DEB.1.00.1602191233170.20796@bonsai2","threadId":"41434","inReplyTo":"CAN2vHUHhqVn8uXaUTdeU5mKuRLQ1084wJu27k4nMJgywOjdOdA@mail.gmail.com","subject":"Re: Windows git bash - child processes see system PATH environment variable instead of user...","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-19T11:33:53Z","receivedAt":"2016-02-19T11:33:53Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Edward,\n\nOn Fri, 19 Feb 2016, Edward Marshall wrote:\n\n> Hey, thanks for getting back to me. I subseuqently found the\n> git-for-windows issues tracker on github so have posted an updated\n> version of this there - not sure where is the best place for issues.\n\nIt is the best place for Windows-specific issues. Thanks for following up!\n\nCiao,\nJohannes\n"}]}