I am unable to open bash profile. I had set the Java and Android path but suddenly it is opening. But when I run echo $PATH it is displaying the paths correctly. Now I need to add path to bash profile.
Could anyone please help me?
Your $PATH is wrong :
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin:/Users/qsgtechnologies/Library/Android/sdk/platform-tools:/Users/qsgtechnologies/Library/Android/sdk/tools
This doesn't use standard default path, and, unless this is totally intentional, I recommend you not to do this.
You've got to fix it running this (note /bin:/usr/bin:):
export PATH=/bin:/usr/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin:/Users/qsgtechnologies/Library/Android/sdk/platform-tools:/Users/qsgtechnologies/Library/Android/sdk/tools:
The next time, be sure to use this syntax:
export PATH=$PATH/YourNewPath:
Since you removed /bin:/usr/bin: you where unable to change your bash profile because bash wasn't able to locate your executables.
Fitting your needs, here's your current bash_profile:
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/qsgtechnologies/Library/Android/sdk
export PATH=$JAVA_HOME/bin:/usr/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
Change it to (note that YourNewEntry is a placeholder for the value you need)
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/qsgtechnologies/Library/Android/sdk
export PATH=$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:/YourNewEntry
Then apply your changes:
source ~/.bash_profile
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.
I'm on a Mac, when I open my shell, it displays the following:
-bash: export: `/Users/jasoncollis/torch/install/bin/torch-activate:/usr/local/bin:/Users/jasoncollis/Library/Enthought/Canopy_64bit/User/bin:/Users/jasoncollis/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin': not a valid identifier
This is my #.bash_profile# file:
# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
PATH=":/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
# added by Anaconda3 4.2.0 installer
export PATH=":/Users/jasoncollis/anaconda/bin:$PATH"
# Added by Canopy installer on 2016-11-10
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make the bash prompt show that Canopy is active, otherwise 1
alias activate_canopy="source '/Users/jasoncollis/Library/Enthought/Canopy_64bit/User/bin/activate'"
VIRTUAL_ENV_DISABLE_PROMPT=1 source '/Users/jasoncollis/Library/Enthought/Canopy_64bit/User/bin/activate'
export PATH=":/usr/local/bin:$PATH"
export LC_CTYPE=en_US.UTF-8
export PATH=":/Users/jasoncollis/torch/install/bin/torch-activate:$PATH"
export PATH=":/Users/jasoncollis/torch/install/bin:$PATH"
I've been trying to search for a solution but nothing I've tried has worked so far. Would be really grateful for any help!
Make sure that you edit the right file. For login shells Bash executes .bash_profile and not #.bash_profile#. The later looks like a backup file created by a text editor or script.
I created a.bash_profile and defined
export PATH=/user/local/bin
rather than
export PATH=/user/local/bin:$PATH
Then, I ran
source ~/.bash_profile
Now none of the command, e.g., ls works. Is there a way to back out this change? Thank you.
If you have fixed your .bash_profile file, you just restart bash to get your $PATH back. If that's not an option, or you can't fix the file externally, you can do export PATH="/bin:/usr/bin:/usr/local/bin", which should give you enough to get to vi or some other text editor so you can fix your .bash_profile, then you can restart bash.
Whenever I open a terminal, a message appear on top of it saying what I wrote in the title.
I think I messed up with the /etc/profile file when trying to get maven work.
I read some infos on exporting variables, but couldn't find my error, since I followed a guide that worked fine for other people.
The profile file I mentioned has these lines at bottom:
JAVA_HOME=/usr/local/java/jdk1.8.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jre1.8.0
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Setting $JAVA_HOME let me use properly Maven, but creates this annoying message. Can you help me?
As others mentioned in the comments, you are trying to export PATH. instead of PATH somewhere. You might want to check /etc/profile, ~/.bashrc and ~/.bash_profilefiles and try to find this invalid export.
The source you provided is technically ok and you don't need to add any $ signs. Your PATH will contain $HOME/bin value twice though. You might want to change it to look like this:
export JAVA_HOME=/usr/local/java/jdk1.8.0
export JRE_HOME=/usr/local/java/jre1.8.0
export PATH="$PATH:$HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin"
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.