editing PATH variable on mac

Macos

Macos Problem Overview


How to edit PATH variable on mac (Lion). I cannot find any file where I can add paths. can someone guide me about it?

Whats the file name? .profile or .bash_profile???

and where I can find it? I have tried

echo 'export PATH=/android-sdk/tools:$PATH' >> ~/.profile

Macos Solutions


Solution 1 - Macos

Open and edit /etc/paths using any text editor.

$ sudo vi /etc/paths

(editing text files with vi)

Note: each entry is separated by a new line

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

Save and close the file. Then restart your terminal.

Solution 2 - Macos

Based on my own experiences and internet search, I find these places work:

/etc/paths.d

~/.bash_profile

Note that you should open a new terminal window to see the changes.

You may also refer to this this question

Solution 3 - Macos

You could try this:

> 1. Open the Terminal application. It can be found in the Utilities directory inside the Applications directory. > 2. Type the following: echo 'export PATH=YOURPATHHERE:$PATH' >> ~/.profile, replacing "YOURPATHHERE" with the name of the directory > you want to add. Make certain that you use ">>" instead of one ">". > 3. Hit Enter. > 4. Close the Terminal and reopen. Your new Terminal session should now use the new PATH.

Quoted from ketio.me tutorial (archived copy).

Solution 4 - Macos

environment.plst file loads first on MAC so put the path on it.

For 1st time use, use the following command

export PATH=$PATH: /path/to/set

Solution 5 - Macos

use

~/.bash_profile

or

~/.MacOSX/environment.plist

(see Runtime Configuration Guidelines)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questioncoure2011View Question on Stackoverflow
Solution 1 - MacosRyan AllenView Answer on Stackoverflow
Solution 2 - Macoscan.View Answer on Stackoverflow
Solution 3 - MacosMasterCassimView Answer on Stackoverflow
Solution 4 - MacosJay SampatView Answer on Stackoverflow
Solution 5 - MacoscodyView Answer on Stackoverflow