Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash/cygwin/$PATH: Do I really have to reboot to alter $PATH?

I wanted to use the Python installed under cygwin rather than one installed under WinXP directly, so I edited ~/.bashrc and sourced it. Nothing changed. I tried other things, but nothing I did changed $PATH in any way. So I rebooted. Aha; now $PATH has changed to what I wanted.

But, can anyone explain WHY this happened? When do changes to the environment (and its variables) made via cygwin (and bash) take effect only after a reboot?

(Is this any way to run a railroad?) (This question is unlikely to win any points, but I'm curious, and I'm also tired of wading through docs which don't help on this point.)

like image 473
behindthefall Avatar asked Jul 14 '09 00:07

behindthefall


People also ask

How do I change the PATH in Cygwin?

For Windows 10, a quick access is to enter "Edit the system environment variables" in the Start Search of Windows and click the button "Environment Variables". Change the PATH variable (double-click on it or Select and Edit), and add the path where your Cywgwin is, e.g. C:\cygwin\bin.

Where are Cygwin files stored?

The Cygwin DLL supports user specific fstab files. These are stored in the directory /etc/fstab. d and the name of the file is the Cygwin username of the user, as it's created from the Windows account database or stored in the /etc/passwd file (see the section called “Mapping Windows accounts to POSIX accounts”).


1 Answers

Try:

PATH="${PATH}:${PYTHON}"; export PATH

Or:

export PATH="${PATH}:${PYTHON}"

the quotes preserve the spaces and newlines that you don't have in your directory names. I repeat "don't".

If you want to change the path for the current environment and any subsequent processes, use something similar to either of the commands above; they are equivalent.

If you want to change the path for the next time you start Bash, edit ~/.bashrc and add one of the above (for example) or edit the existing PATH setting command that you find there.

If you want to affect both the current environment and any subsequent ones (i.e. have an immediate and a "permanent" affect), edit ~/.bashrc and do one of the following: type one of the first two forms shown above or source the ~/.bashrc file. Sometimes, you may not want to do the sourcing if, for example, it would undo some temporary thing that you're making use of currently like have some other variables set differently than ~/.bashrc would set (reset) them to.

I don't think you need to worry about hash unless you're either doing some serious rearranging or adding some local replacements for system utilities perhaps.

like image 93
Dennis Williamson Avatar answered Sep 22 '22 08:09

Dennis Williamson