How to Get Back the macOS Default $PATH?

Hey Folks

I think I am in big trouble ....

Maybe I have messed up my $PATH - and I didn't know that I did...

Thinking about getting more Shell Scripting - Skills and writing a bash profile I yesterday executed this Terminal command echo $PATH to get my default Path....

This Is what I got as answer from Terminal....

/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin

Thought about trying the BibTex Suite a couple months ago but removed it from my System because it was too much for me to configure at this time...

It seems that I haven't removed it Correctly form my System....

  • How can I get my default $Path back?
  • How to get rid of the rest of the BibTex Suite?

System: macOS High Sierra

Hope someone can help me

greetings from Germany

Hey Tobias,

BIG Trouble? I don't really think so.

The $PATH is where the terminal looks for executables, and having an extra directory or two isn't very likely to cause major problems. Although – under extreme circumstances it could cause problems.

Apparently you already have a bash profile – .profile – .bashrc – or something similar.

Open your home directory in the Finder.

Press .

This will reveal the invisible items in the directory.

Run this in the Terminal:

find ~ -name ".*" -maxdepth 1

It will display the invisible items in your home directory as well.

You can then eyeball or use the Find in the Terminal to look for strings like:

  • .bash_profile
  • .bash_login
  • .profile

Once you've found your customization file, you can edit it appropriately.

Save a backup copy of the original, before you start messing with it though.

-Chris

Thank you for your quick answer Chris

I know that there is a default File .... But I am just at the beginning writing and editing a .profile or .bashrc ....

  • what can I do at this POV ?
  • How can I get rid of the rest from the BibTex Suite?

Edit:

this is what my .bash_profile is currently containing....


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


What is POV?

I've explained that.

You have to find the current working Terminal customization (text) file where the path has been altered and edit it.

-Chris

Point of View

In his Article Armin Briegel wrote

For example, macOS sets the PATH environment variable to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin by default

so I have to write into my .bash_profile something like this:

PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export PATH

is that correct ?

Edits do not notify other users, so it's better to create a new post. I only saw the edit by chance.

This clearly doesn't contain /Library/TeX/texbin ...

Agh!  You'd have never found it – it's well hidden – and the Google was NOT kind when searching for how BibTex alters the system path.

Look here:

/private/etc/paths.d/

-Chris

That would be a bandaid.

You want to fix the problem. See Post #7.

-Chris

I'm sorry Chris .... only thought about mentioning that I have edit my post... will make it better next time.....

Yes you're right .... I wasn't able to find anything..... it is really tricky... :joy:

but you have nailed it ....

that is a shot of my /private/etc/paths.d/

Bildschirmfoto 2021-06-24 um 14.46.07

It is only that single File in there - what to do with it ?

just trash or anything else?

Okay maybe I have found out ....

Opened Terminal and executed this Command: cat /etc/paths.d/TeX

this was the output: /Library/TeX/texbin

After that I opened /Library/ and found the Directory TeX

Bildschirmfoto 2021-06-24 um 15.16.08

1 Like

Deleted both - the TeX Directory and the TeX file

now my Terminal gives me this using echo $PATH:

/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
1 Like

Just to add a few additional notes:

  • While /etc/paths.d/ is a standard way to add things to the $PATH there are a lot of apps that do not use it. See man path_helper for more info on it.

  • Newer versions of macOS use zsh as the default login shell, so you should look for changes not only in ~/.bash_profile, ~/.profile and ~/.bash_login but also ~/.zprofile, ~/.zshenv and ~/.zshrc

  • If you are still stuck, check /etc/profile and /etc/bashrc as well as /etc/zprofile, /etc/zshenv and /etc/zshrc just to make sure that some over-eager developer didn't decide to modify those directly (which they should not, but potentially could, so…).

2 Likes

Thanks @tjluoma

I'll look into that when using newer Versions of macOS

greetings from Germany

It's shameful that Bash, Zsh, etcetera don't have a command to list all active config files...

-Chris

Question, does Time Machine save these files?

@hello - As long you don't exclude them I think they should be saved with Time Machine so they can be easily restored.....

Stay safe

Tobias

1 Like