Question

Lately I tried to made some changes to paths in my .bash_profile.
After I tried to validate these changes with source .bash_profile and got -bash: : command not found,
I have also noticed that when I open the shell, before the execution of any command, it stands already "-bash: : command not found"...
Obviously, changes made to .bash_profile weren't taken into consideration by the system niether...
Please, help! I guess that I messed with the .bash_profile too much, have no idea how to fix it...

Contents of .bash_profile:

cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH=/Users/usrname/TreeTagger/cmd:$PATH
export PATH= /Users/usrname/TreeTagger/bin:$PATH
export UIMA_HOME= $/Users/usrname/apache-uima
export PATH=$PATH:$UIMA_HOME/bin
export HEIDELTIME_HOME='/Users/usrname/Downloads/heideltime-kit/'
export TREETAGGER_HOME='/Users/usrname/TreeTagger'
source $HEIDELTIME_HOME/metadata/setenv

Updated contents of .bash_profile:

cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH="/Users/usrname/TreeTagger/cmd:$PATH"
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
export UIMA_HOME="/Users/usrname/apache-uima"
export PATH=$PATH:$UIMA_HOME/bin
export HEIDELTIME_HOME="/Users/usrname/Downloads/heideltime-kit/"
export TREETAGGER_HOME="/Users/usrname/TreeTagger"
source $HEIDELTIME_HOME/metadata/setenv

Full shell output after last quotes' correction:

Last login: Thu Jul 31 19:07:05 on ttys000
-bash: : command not found
usr:~ usrname$ cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH="/Users/usrname/TreeTagger/cmd:$PATH"
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
export UIMA_HOME="/Users/usrname/apache-uima"
export PATH="$PATH:$UIMA_HOME/bin"
export HEIDELTIME_HOME="/Users/usrname/Downloads/heideltime-kit/"
export TREETAGGER_HOME="/Users/usrname/TreeTagger"
source $HEIDELTIME_HOME/metadata/setenv


usr:~ usrname$ source .bash_profile
-bash: : command not found

Edit with echo commands:

  cat .bash_profile
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
##
# MacPorts Installer addition on 2014-03-24_at_12:05:55: adding an appropriate PATH variable for use with MacPorts.
### Your previous /Users/usrname/.bash_profile file was backed up as /Users/usrname/.bash_profile.macports-saved_2014-03-24_at_12:05:55
##export PATH="/Users/usrname/anaconda/bin:$PATH"
# added by Anaconda 1.9.1 installer
##Additional binary folders
export PATH="/Users/usrname/TreeTagger/cmd:$PATH"
export PATH="/Users/usrname/TreeTagger/bin:$PATH"
export UIMA_HOME="/Users/usrname/apache-uima"
export PATH="$PATH:$UIMA_HOME/bin"
export HEIDELTIME_HOME="/Users/usrname/Downloads/heideltime-kit/"
export TREETAGGER_HOME="/Users/usrname/TreeTagger"
echo before
source $HEIDELTIME_HOME/metadata/setenv
echo after


usr:~ usrname$ source .bash_profile
-bash: : command not found
usr:~ usrname$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

Edit +bash version:

echo $BASH_VERSION
3.2.51(1)-release
usr:~ usrname$ source ./.bash_profile
-bash: : command not found

Edit +after set -x was added to .bash_profile:

usr:~ usrname$ source ./.bash_profile
++ $'\016'
-bash: : command not found
++ update_terminal_cwd
++ local 'SEARCH= '
++ local REPLACE=%20
++ local PWD_URL=file://usr.local/Users/usrname
++ printf '\e]7;%s\a' file://usr.local/Users/usrname
Was it helpful?

Solution

This line:

export PATH= /Users/usrname/TreeTagger/bin:$PATH

is the problem. In a variable assignment, including an export, you can't have spaces around the =. With the added space, it sets $PATH to the empty string.

Change it to:

export PATH=/Users/usrname/TreeTagger/bin:$PATH

For safety, you should add double quotes:

export PATH="/Users/usrname/TreeTagger/bin:$PATH"

just in case there are any special characters in the value of $PATH.

You have the same problem with UIMA_HOME.

UPDATE :

Based on later comments, you appear to have a stray control character in your .bash_profile. With set -x it's displayed as $'\016'. bash tries to treat that as a command name, and not surprisingly is unable to find it. Edit your .bash_profile and delete that character.

(The other errors needed to be corrected anyway.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top