where is $PATH set? Specifically where is my mac port path being set?
On my system, MacPorts installer put it into /etc/profile
.
The (full?) list of files is as follows (in the order bash
reads them):
/etc/profile
/etc/bashrc
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc
Where does $PATH get set in OS X 10.6 Snow Leopard?
When bash
starts it reads the following files every time you login. For the purposes of OS X, this means every time you open a new Terminal
window.
/etc/profile
~/.bash_profile
~/.bash_login (if .bash_profile does not exist)
~/.profile (if .bash_login does not exist)
When you start a new shell by typing bash
on the command line, it reads .bashrc
OS X also uses ~/.MacOSX/environment.plist
to set more environment variables, including paths if necessary.
Finally, /etc/paths
and /etc/paths.d
are read by the shell too.
/opt/local/bin
etc. are added in ~/.tcshrc
by MacPorts. Also be sure to look in ~/.cshrc
.
Locate MacPorts package?
Your PATH is incorrect. It appears to be picking up another Python 2.7, likely one installed using a binary installer from python.org or elsewhere, and not the MacPorts installed one. Try removing the the /Library/Frameworks/Python.framework/Versions/2.7/bin
from PATH or just invoke the MacPorts Python directly:
/opt/local/bin/python2.7
MacPorts and the bash PATH
Without more information, it's hard to guess what behavior you are seeing and what you expect to see. MacPorts does provide port select
options for some of the commands you mention like python
and ipython
but does not yet for pip. In general, MacPorts installs Python scripts with version-specific suffixes, so independent of port select
options, you should find those commands with their suffix, for example:
$ port select --list ipython
Available versions for ipython:
ipython27
ipython32 (active)
none
$ which ipython
/opt/local/bin/ipython
$ which ipython-2.7
/opt/local/bin/ipython-2.7
$ port select --list pip
Warning: Unable to get active selected version: The specified group 'pip' does not exist.
Error: The 'list' command failed: The specified group 'pip' does not exist.
$ which pip
$ which pip-2.7
/opt/local/bin/pip-2.7
BTW, neither pip
nor ipython
are supplied by Apple with OS X system Pythons, so it's not clear what you mean by bundled OS X defaults. Perhaps you installed versions of these to the system Python 2.7. If so, by default, you would see them with /usr/bin/python2.7
and/or installed in /usr/local/bin
and /Library/Python/2.7
.
Update: Until MacPorts provides a port select pip
option (as requested in the MacPorts issue linked above), you should be able to have pip
execute the MacPorts version by modifying your .profile
to add the Python framework bin directory at the head of the paths:
export PATH=/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:...
Update 2014-04: MacPorts now does provide a port select pip
option so you should no longer need to do the PATH
hack.
$ sudo port select pip
Available versions for pip:
none (active)
pip27
pip33
$ sudo port select pip pip27
Selecting 'pip27' for 'pip' succeeded. 'pip27' is now active.
$ hash
$ which pip
/opt/local/bin/pip
Setting PATH environment variable in OSX permanently
You have to add it to /etc/paths
.
Reference (which works for me) : Here
How do I change $PATH to default on a mac?
Rename your ~/.bash_profile
file by running the following in Terminal:
rm ~/.bash_profile
and restart the Terminal. This should restore the system default path for you. To view the current value of PATH
variable, type:
echo $PATH
in the Terminal. Do not simply type $PATH
at the prompt as it would expand the value of the PATH
variable and try to run it as a command.
To make the sqlpackage
command available in your command PATH, add the sqlpackage files as instructed under a directory named sqlpackage in your Home directory, and then run the following on the Terminal:
export PATH="$PATH:~/sqlpackage"' >> ~/.bash_profile
followed by:
source ~/.bash_profile
This should set you up.
Getting a warning when installing homebrew on MacOS Big Sur (M1 chip)
I had the same issue today, on Mac OS Big Sur (with M1 chip).
The problem is indicated in the warning : Warning: /opt/homebrew/bin is not in your PATH.
It seems that it is the directory where the binaries of hombrew are put.
To resolve, you can do :
- Edit your
~/.zshrc
or~/.bashrc
with at the end of file:
export PATH=/opt/homebrew/bin:$PATH
After this, tap source ~/.zshrc
in your terminal or restart it.
For more infos about the current status of Homebrew on Mac with a M1 chip :
Apple Silicon support in Homebrew
Edit :
As mentioned by @kangkyu in this comment, Homebrew is changing to version 3.0.0 which supports officially Apple Silicon. If you have a prior version just brew update
.
Failed to export PATH on mac
You are using bash (or ksh) syntax which doesn't work in fish.
The fish docs cover setting the PATH here: http://fishshell.com/docs/current/tutorial.html#tut_path
The syntax you want is:
set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin
npm global path prefix
Extending your PATH
with:
export PATH=/usr/local/share/npm/bin:$PATH
isn't a terrible idea. Having said that, you shouldn't have to do it.
Run this:
npm config get prefix
The default on OS X is /usr/local
, which means that npm will symlink binaries into /usr/local/bin
, which should already be on your PATH
(especially if you're using Homebrew).
So:
npm config set prefix /usr/local
if it's something else, and- Don't use
sudo
with npm! According to the jslint docs, you should just be able tonpm install
it.
If you installed npm as sudo (sudo brew install
), try reinstalling it with plain ol' brew install
. Homebrew is supposed to help keep you sudo
-free.
Related Topics
How to Add Text After Last Pattern Match Using Ed
Why Would the Elf Header of a Shared Library Specify Linux as the Osabi
How to Keep Program Running in Background in Ash Shell
How to Install Rpy2 via Conda Using Default R Installation
R Package Installation in Linux
Will Data Written via Write() Be Flushed to Disk If a Process Is Killed
Native Linux App to Edit Win32 Pe Like Reshacker
Linux Zip and Exclude Dir via Bash/Shell Script
Substitution on Range of Lines
Linux Command Ambiguous Redirect
Stop on Newline When Using Read(...)
Dockerfile Cmd 'Command Not Found'
How to Get Gcc to Skip Errors, But Still Output Them
Unix How to Block Unix/Linux 'Wall' Messaging
Average of Multiple Files Without Considering Missing Values
Permission Denied (Publickey), on Linux Aws Server How to Fix It
Can Someone Explain How This "Shellshock" Code Works in Shell