unable to update path on mac os mavericks - macos

Here is the contents of my .bash_profile
PS1=">>"
alias ls='ls -G'
export CLICOLOR=1
export LSCOLORS=Gxfxcxdxbxegedabagacad
#set SCALA_HOME variable.
export SCALA_HOME=/usr/local/bin/scala
# Added by Canopy installer on 2014-09-22
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make bashprompt show that Canopy is active, otherwise 1
VIRTUAL_ENV_DISABLE_PROMPT=1 source /Users/muralidharn/canopy/bin/activate
#add ipython path to actual PATH variable.
export PATH=$PATH:/Users/muralidharn/canopy/bin
#set JAVA_HOME , this is the way mac recommends that we do it.
#export JAVA_HOME=$(/usr/libexec/java_home)
#add maven to path
export PATH=$PATH:/Users/muralidharn/apache-maven-3.2.3/bin
export PATH=$PATH:/mynewpath
# Added by Canopy installer on 2014-09-22
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make bashprompt show that Canopy is active, otherwise 1
VIRTUAL_ENV_DISABLE_PROMPT=1 source /Users/muralidharn/Library/Enthought/Canopy_64bit/User/bin/activate
My PATH variable is not getting updated with any of the paths that I am exporting. Could someone tell me what I'm doing wrong as I have a feeling its something very silly that I'm just not seeing. I tried restarting the terminal , restarting my computer , source .bash_profile etc... already.
Thanks in advance for your help.

I am not sure if this will work for you, but I would give this syntax a try:
export PATH=\
/usr/local/bin:\
/usr/local/sbin:\
/opt/local/bin:\
/opt/local/sbin:\
$HOME/Dropbox/bin:\
$HOME/bin:\
$HOME/usr:\
/usr/X11/bin:\
/usr/bin:\
/bin:\
/usr/sbin:\
/sbin:\
/Homes/usr/local/bin:\
/vnmr/bin:\
$HOME/Rosetta/main/source/bin
(obviously, use your paths above. This is just an example of how I set mine up).
Also, put this at the top of your bash profile:
#!/bin/bash

Related

Touch, open, ls not working on Mac 10.15.6 terminal, PATH issues

I have been trying to use touch, open and ls commands but this error is returned - -bash: open: command not found. It has always worked until today. This started happening after I added the Postgres path to PATH. Additionally, my PATH looks quite messy and I have absolutely no understanding of that.
Note - I have been through various solutions here on PATH and bash command not found but none seem to be working. Another thing is I can’t use stuff like sudo. I am adding my .bash_profile here if it helps -
# >>> conda initialize >>>
# !! Contents within this block are managed by ‘conda init’ !!
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
PATH=“${PATH}”
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
export PATH = /Users/arif/Library/Python/2.7/bin
export PATH = /Users/arif/Library/Python/2.7/bin:$PATH
echo “source /usr/local/bin/virtualenvwrapper.sh” >> ~/.bash_profilesource /usr/local/bin/virtualenvwrapper.sh
export PATH=/usr/local/opt/ruby/bin:$PATH
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
export PATH=/Applications/Postgres.app/Contents/Versions/latest/bin(ScrapProj) Arifs-MacBook-Air:scraper_app arif$ python3
Please help me fix this, Thanks!
the contents of your PATH gets overwritten because the "previous" PATH is not (always) added back when you put a new directory. that is why you end up with just Postgres bin directory at the end and the basic unix tools (ls, touch, etc..) cannot be found.
I tried to fix the issues in your .bash_profile:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
# these should already be in the PATH, but re-adding them wont hurt...
export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
# add other directories to the PATH here remembering to append (previous) PATH at the end
PATH="/Users/arif/Library/Python/2.7/bin:$PATH"
PATH="/usr/local/opt/ruby/bin:$PATH"
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:$PATH"
PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
echo “source /usr/local/bin/virtualenvwrapper.sh” >> ~/.bash_profilesource /usr/local/bin/virtualenvwrapper.sh

Bash PATH is not a valid identifier

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.

Unable to open bash profile on OSX

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/qsgte‌​chnologies/Library/Android/sdk/platform-tools:/Users/qsgtechnologies/Library/Andr‌​oid/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/qsgte‌​chnologies/Library/Android/sdk/platform-tools:/Users/qsgtechnologies/Library/Andr‌​oid/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

Java_HOME not found when changed shell from Bash to Zsh on OSX?

This is weird, I have set JAVA_HOME for my mac which can be found when I am using bash shell, but if I change shell, I get a message saying JAVA_HOME not set. What could be going on here?
I stumbled upon your question when trying to solve the same issue while migrating from bash to oh-my-zsh. The reason it's not there is that there is no code setting it for zsh but there was for bash. Generally theres something exporting JAVA_HOME whenever a new bash window is opened so it's always set for you. There is a good thread where this might be happening on the Unix & Linux StackExchange site.
To do the same thing in zsh, you can edit the .zshrc which is run every time zsh starts. I found a sample .zshrc which got me most of the way. The key line being:
export JAVA_HOME=`/usr/libexec/java_home`
Here is the file which I appended to the end of my existing ~/.zshrc file:
#zshrc, interactive shell settings
export ZSH=$HOME/.zsh
# emacs integration
[[ $EMACS = t ]] && unsetopt zle
# env
if [[ -e /usr/libexec/java_home ]]; then
export JAVA_HOME=`/usr/libexec/java_home`
fi
if [[ -e /usr/local/lib/node_modules ]]; then
export NODE_PATH=/usr/local/lib/node_modules
fi
# path
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
export PATH=/opt/usr/sbin:/opt/sbin:/opt/usr/bin:/opt/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PATH=$HOME/.cabal/bin:$PATH
export PATH=$HOME/.gem/ruby/1.8/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$HOME/.bin:$PATH
setopt null_glob
# source all files in zsh root
for include in $ZSH/*.zsh; do
source $include
done
# source all non-controlled files
for include in $ZSH/private/*.zsh; do
source $include
done
unsetopt null_glob
Then source ~/.zshrc to run in the current shell (or just start a new one) and you should be able to see that it is set with export | grep JAVA_HOME.
I also ended up running mkdir ~/.zsh to create the directory this is looking for and removing the .cabal and .gem lines as they were not needed for me.
I have just installed Mac OS Catalina Version 10.15 and found that environment variables such as JAVA_HOME and others that have been set in my .bash_profile :
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_HOME=/Users/mynziak/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export M2_HOME=/usr/local/Cellar/maven/3.6.2/libexec
export M2=${M2_HOME}/bin
export PATH=${PATH}:${M2_HOME}/bin
are not set in fact!
I saw % in terminal instead of general $ that means you are using a zsh shell instead of bash shell. With Catalina zsh is now the default shell and bash will be completely gone in the future.
oh-my-zsh shell:
https://ohmyz.sh/
So you have to setup all environment variables in .zshrc file.
I just copy-pasted every variables from .bash_profile in to .zshrc and re-opened terminal.
Files .bash_profile and .zshrc are hidden (cmd+shift+. - show hidden files in finder) but can be found in path:
/Users/mynziak/.zshrc
but use own username!
When you set JAVA_HOME in a shell, then it is active and available only for that context, and it will be gone when you close that shell.
Instead either change global environment (or) your .bashrc to include it. So that every time you start a shell, the variable will be available.
edit the .profile or .bash_profile to include the JAVA_HOME.
export JAVA_HOME=`/usr/lib....`
and also below command will return the path for java home directory.
/usr/libexec/java_home -v 1.7
where 1.7 is the version you want.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
export PATH=$JAVA_HOME/bin:$PATH
Add above 2 lines in ~/.bashrc or ~/.zshrc and reload the file using source command.

MacOS source ~/.bash_profile disabled everything

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.

Resources