Jacky Wang
Jacky Wang

Reputation: 3490

Failed to export PATH on mac

I added my python bin folder to environment variable PATH,

export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/2.7/bin

But failed with the following statement

set: Warning: path component /usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin'?
set: Warning: path component /usr/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin'?
set: Warning: path component /bin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin'?
set: Warning: path component /usr/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin'?
set: Warning: path component /sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory...

What happened? I just do as many other do(Google Search). The shell used is fish.

Upvotes: 1

Views: 2836

Answers (2)

Sochy
Sochy

Reputation: 66

I have tried with my Macbook Pro, it working fine by edit file ~/.bash_profile. You can see example below: But this work for me only temporary, after close terminal I need to run source ~/.bash_profile again

set JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
set MAVEN_HOME /opt/apache-maven-3.3.9/bin
set XAMP_HOME /Applications/XAMPP/xamppfiles/bin
set ANDROID_HOME /Users/sochy/Documents/sdk
set ZIPALIGN /Users/sochy/Documents/sdk/build-tools/23.0.2
set GOPATH $HOME/go
set PORT /opt/local/bin
set PATH $PATH $JAVA_HOME $MAVEN_HOME $XAMP_HOME $ANDROID_HOME $ZIPALIGN $GOPATH $PORT $HOME/flutter/bin

Another solution I try below for permanently configure by edit file source ~/.bash_profile and then restart terminal

export JAVA_HOME=Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
export MAVEN_HOME=opt/apache-maven-3.3.9/bin
export XAMP_HOME=Applications/XAMPP/xamppfiles/bin
export ANDROID_HOME=Users/sochy/Documents/sdk
export ZIPALIGN=Users/sochy/Documents/sdk/build-tools/23.0.2
export GOPATH=$HOME/go
export PORT=opt/local/bin
export PATH=${PATH}:$JAVA_HOME:$MAVEN_HOME:$XAMP_HOME:$ANDROID_HOME:$ZIPALIGN:$GOPATH:$PORT:$HOME/flutter/bin

Upvotes: 0

Tim
Tim

Reputation: 6509

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

Upvotes: 5

Related Questions