new PATH isn't showing up in new console

3

Add the path to Mongo to my $PATH in git-bash:

jcollum@MACHINE /c/Program Files/mongodb-win32-x86_64-2.2.2/bin                                                           
$ PATH=$PATH:/c/Program\ Files/mongodb-win32-x86_64-2.2.2/bin                                                                 

jcollum@MACHINE /c/Program Files/mongodb-win32-x86_64-2.2.2/bin                                                           
$ echo $PATH                                                                                                                  
/c/Users/jcollum/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Program Files/ConEmu/ConEmu:/c/Windows/system32:/c/Windows:/c/Windows
/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/Program Files/TortoiseGit/bin:/cmd:/c/Program Files/Microsoft/We
b Platform Installer/:/c/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/:/c/Program Files (x86)/Windows Kits/8.0
/Windows Performance Toolkit/:/c/Program Files/Microsoft SQL Server/110/Tools/Binn/:/c/Program Files/mongodb-win32-x86_64-2.2.
2/bin                                                                                                                         


jcollum@MACHINE /c/Program Files/mongodb-win32-x86_64-2.2.2/bin
$ which mongod
/c/Program Files/mongodb-win32-x86_64-2.2.2/bin/./mongod

That all looks right. But when I start a new console or restart ConEmu, the path is gone. Is it possible to get these changes to 'stick' using Git-Bash on Win7?

Got the 'how to' for PATH here:

https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path

jcollum

Posted 2013-01-03T22:40:52.250

Reputation: 3 737

Edit the PATH variable in your .bashrc file. – Blender – 2013-01-03T22:42:03.763

Answers

4

When you start new console - it inherits environment strings (%PATH% also) from parent process (ConEmu).

When you change %PATH% in your shell - it applies to this shell and its children processes.

If you need to fixate this temporarily environment changes - you may execute

ConEmuC /export PATH

This will "copy" your current %PATH% value to ConEmu GUI and it will be applied to all new ConEmu's consoles.

BTW, why you not tag your question with "conemu"?

Maximus

Posted 2013-01-03T22:40:52.250

Reputation: 19 395

Wasn't sure that it was relevant, since I'm running git-bash inside of ConEmu. I gotta say, you are really on top of any ConEmu posts on the SO network. Well done sir! – jcollum – 2013-01-04T17:10:29.633

Oh I'm getting this (120727c x64): Parsing command line failed (/C argument not found): "c:\Program Files\ConEmu\ConEmu\ConEmuC.exe" "C:/Program Files (x86)/Git/export" PATH – jcollum – 2013-01-04T17:17:17.103

First of all, update to the latest ConEmu version. Also, as far as I remember, switches started with "/" char must be escaped, may be ConEmuC //export PATH will help. – Maximus – 2013-01-04T18:33:07.813

2

You need to put that PATH setting command into your .bash_profile or .bashrc file. Just setting it at the command prompt only does it for your currently active shell.

Carl Norum

Posted 2013-01-03T22:40:52.250

Reputation: 2 621

OK but can I edit the PATH and make that 'stick' in Windows? Windows proper doesn't know about .bash_profile. – jcollum – 2013-01-03T23:44:19.093

@jcollum, your git-bash does, though. It has to get it from somewhere. Check your docs. YOu might get away with it by adding it to the system path (My Computer->Properties->Advanced->Edit Environment Variables or something like that, IIRC). – Carl Norum – 2013-01-03T23:52:53.437

Right, I should have mentioned I know how to do it the 'standard' way in windows, I was just curious why that wasn't getting down to the real %PATH%. I suppose git-bash is grabbing the windows path variable and then appending any values from .bash_profile. – jcollum – 2013-01-04T00:58:21.400

1

As Carl said, setting PATH at the command prompt does not create a lasting effect.

Try adding:

export PATH=$PATH:/c/Program\ Files/mongodb-win32-x86_64-2.2.2/bin 

to a file called .bashrc under your home directory. For Windows, this is usually located at C:\Users\<your user name> folder. You can find out for sure by using echo $HOME.

yarian

Posted 2013-01-03T22:40:52.250

Reputation: 141