MacOS – Restore path to be read from /private/etc/paths

macospath

I used the how to from
https://docs.aws.amazon.com/cli/latest/userguide/cli-install-macos.html

to install AWS CLI on macOS.
After executing command source ~/.bash_profile it seems that my default PATH location from file /private/etc/paths was lost.

/private/etc/paths file content:

/usr/bin/vim /private/etc/paths

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

~/.bash_profile file content:

# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH

For example next command cant find the location of basic files installed in /usr/bin/:
-bash: vim: command not found

Is it a way to restore path to be reading from /private/etc/paths?

echo $PATH
/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/<myusername>/bin:/Library/Python/3.6/bin/

Also I can't use the same command to reread from the location

source /private/etc/paths
-bash: /usr/local/bin: is a directory
-bash: /usr/bin: is a directory
-bash: /bin: is a directory
-bash: /usr/sbin: is a directory
-bash: /sbin: is a directory

Best Answer

  1. Fix your /private/etc/paths content:

    The default content is:

    /usr/local/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    

    If you want to include /usr/bin/vim (but only if vim is a folder containing some executables - the macOS installed vim exec is /usr/bin/vim!) modify the content to:

    /usr/local/bin
    /usr/bin/vim
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    
  2. You have another (superior) export PATH line somewhere (i.e. bash config files) with the following content:

    export PATH="/Users/<myusername>/bin:/Library/Python/3.6/bin/:*"
    

    with *= either completely missing or a falsely defined PATH variable (e.g. Path instead of PATH)

    At least it doesn't inherit the standard paths defined by /private/etc/paths

    This first PATH export and the second in your ~/.bash_profile then yield something broken like:

    /Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/<myusername>/bin:/Library/Python/3.6/bin/ 
    

    as PATH