-1

Confused about how to find my $PATH file to edit it

When I type $PATH I get back

zsh: no such file or directory: /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

which is strange it says "no such file or directory" then gives what looks like would be the contents of such a file.

I need to add a PATH so was following along to a video that said to cd to ~ and ls -la to show hidden files and open up the .bash_profile and that is where all the paths are and i could add one.

However it seems I now run zsh. I did some more searching and found someone said it is now .zshrc but that file isn't in my path.

How can I find from what file the $PATH is coming from?

Thank you!

EDIT: https://superuser.com/questions/886132/where-is-the-zshrc-file-on-mac This says the .zshrc by default doesn't come with the new Big Sur update, so to create it. But, then where has my computer been getting the PATH's from all this time?

  • How do you add the path to `PATH`? Show the code in `.bash_profile` – Ted Lyngmo Jul 14 '22 at 13:39
  • `cd ~ && grep -r 'PATH='` will show you in which files in your home directory the path variable gets set or modified. **DO NOT MODIFY THESE!** Instead you can modify the `$PATH` variable by adding `PATH=$PATH:/dir/that/you/want/to/add/to/path` to your .zshrc or similar file – mashuptwice Jul 14 '22 at 13:44
  • 1
    If you want to see your current path, type `echo $PATH`. If you just type `$PATH`, the shell treats it as a command and tries to run it, and that fails because there is not such command. – Robert Jul 14 '22 at 18:59

1 Answers1

0

You typed

$PATH

at the prompt, which is evaluated to

/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

which then zsh tries to execute as any other command you type, and got

zsh: no such file or directory: /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

because that long sequence of dirs and separators is not the name of a command file or directory.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134