I have installed GO on my Mac Book using the 10.8+ installer from golang.org, and I have set up a workspace. After running both these commands: export GOPATH=$HOME/go and export PATH=$PATH:$GOPATH/bin, echoing the GOPATH does return a value of /Users/dipen/go; however, after restarting the terminal, the echoing the GOPATH returns nothing. How can I fix this?
Add these lines to your ~/.bashrc or ~/.bash_profile:
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
Related
Usually I will nano .zsh_profile
Then I will edit the path
#PYTHON
export PATH=/Users/ffff/Library/Python/3.8/bin:$PATH
# JAVA
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
#ANDROID
export ANDROID_HOME=/Users/ffff/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
then I will save and exit
Then I will
source .zsh_profile
I will test the Java and ADB all is good, but one I open a new Terminal from my mac, it will say ADB and JAVA and Android_HOME not found
Why is it not persist? Did I miss out anything? My mac version is 12.2.1
The .zsh_profile file, has no special meaning. This is probably a confusion form Bash, where the bash_profile is executes for login shells. In Zsh, that equivalent would be ~/.zprofile. You might have some code in your .zshrc file, that overrides the PATH variable with something else. Because, as oppsed to .zprofile, the .zshrc file gets executed for every interactive non-login shells.
So my advice, checkout .zshrc and see if there's something overriding the PATH there, if so, maybe you want to change that, and NOT to execute these commands you want to add for every time a shell is opened, you should put them in .zprofile, so they only get executed once at login.
When i use:
nano .bash_profile
the terminal show me:
export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH
# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
export PATH="/Applications/MAMP/Library/lib"
export PATH="/Applications/MAMP/Library/bin"
#XAMPP
#export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH"
#export PATH="/Applications/XAMPP/xamppfiles/lib:$PATH"
But when i open a new terminal only shows. echo $PATH prints.
/Applications/MAMP/Library/bin
The problem is that when i execute a command the terminal returns :
command not found
I need to execute this command for the terminal to operate properly
export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH
and echo $PATH prints.
/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:/Applications/MAMP/Library/bin
What can i do to open and edit the correct shell PATH ?
You are overiding your PATH variable every time you export. your .bash_profile should be
export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin
export PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH="/Applications/MAMP/Library/lib:$PATH"
export PATH="/Applications/MAMP/Library/bin:$PATH"
this way your current path is added to the end of the new path variable
So I was trying to setup the Go programming environment on my Mac and add the necessary directory to the path by modifying the .bash_profile accordingly. After saving the .bash_profile, I tried running "go version" for example but it still didn't work.
After a bit of searching I found that if i did the following:
source ~/.bash_profile
The go version would work. Which it does but it seems that my PATH has been changed since commands such as: nano, vi, ls, sudo etc do not work anymore.
Is there a way of recuperating my initial environment PATH?
Thanks in advance!!
:D
PS - let me know if my issue is not clear
Note that your path is likely just "broken" for your current shell session: Mac OS X doesn't strictly use .bash_profile for your PATH.
My guess is that you didn't write out export PATH=$PATH:$GOPATH/bin and export GOPATH=/Users/sSmacKk/go/ (or wherever you wanted to set it) correctly: if you forget to assign the existing path back to your new path, you'll have problems.
Run path_helper from /usr/libexec/path_helper (which would normally be on your path!)
Add the lines: export GOPATH=/wherever/you/want/ and then export PATH=$PATH:$GOPATH/bin to your .bash_profile
Save and exit from your text editor and then source .bash_profile.
I have tried to set env var in Mac.
$ open ~/.bash_profile
shows:
export ADB_PATH=~/MyWorkspace/sdk/platform-tools/adb
export PATH=$PATH:$ADB_PATH
I have restarted the machine but no effect:
$ adb
-bash: adb: command not found
what can be wrong?
update
have tried this too, with no help:
export ADB_PATH=~/MyWorkspace/sdk/platform-tools
export PATH=$PATH:$ADB_PATH/adb
or
export PATH=$PATH:~/MyWorkspace/sdk/platform-tools
Entries in the PATH environment variable should be directories, not individual binaries. Change your PATH to:
export PATH=$PATH:~/MyWorkspace/sdk/platform-tools
I keep on getting the "TERM environment variable not set." error when I work with svn commands on my Mac terminal.
I thought I had set up my profile by doing:
export SVN_EDITOR=/usr/bin/nano
export EDITOR=/usr/bin/nano
in .profile and .bash_profile, reset the terminal and it still gives me that error.
Any help?
Add this to your profile:
export TERM=xterm-color