0

When i try to do ls in the terminal, it says command not found.

Before I broke everything, the output of echo $PATH was something like this:

/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:

I was trying to follow along with some threads but I don't seem to understand what specifically I need to run to change my .zshrc file (this thread said to change PATH variable in .zshrc: commands not found on zsh)

So, I pasted this into the terminal:

echo "export PATH=/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:" >> ~/.zshrc

And then source ~/.zshrc"

But then i got this response

/Users/gabrijelagavric/.oh-my-zsh/oh-my-zsh.sh:117: command not found: rm
detect-clipboard:33: command not found: uname
/usr/local/opt/chruby/share/chruby/chruby.sh:5: command not found: ls
/Users/gabrijelagavric/.zshrc:export:107: not valid in this context: /Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:``` 

3 Answers3

4

The way I fixed this was following the answer provided by "user1934428" in their comment (though they didn't actually answer it so I don't know how to specify they resolved it"

Their suggestion was to edit the file in a text editor.

  1. opened vs code
  2. file > open
  3. show hidden files (.zshrc) via cmd+shift+"." (for mac)
  4. made changes
  5. saved

Thank you user1934428, your solution helped. Thank you to Mashuptwice and Chapner as well for answering as well.

0

You've added the new $PATH variable as last line (>>) to your .zshrc file. Remove the last line of the file to revert the changes.

If you want to add a path to $PATH in the future, you can use PATH=$PATH:/new/path/appended/to/variable to add something to the variable, without completely replacing it.

mashuptwice
  • 640
  • 3
  • 18
  • Or in `zsh` ,`path+=( /new/path/appended/to/variable )`. Appending to the tied array takes care of all the corner cases involved in handling `:`s correctly. – chepner Mar 29 '22 at 13:30
  • Thank you! So, as of now my output from echo $PATH is /usr/local/var/postgresql@12 – mostlyConfused Mar 29 '22 at 19:49
  • That doesn't seem right, I need to revert it back to ```/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:``` . Is it safe to use echo to delete the line "/usr/local/var/postgresql@12" and add the stuff I need back in? – mostlyConfused Mar 29 '22 at 19:52
  • oh wait i just opened it via vs code and edited that way(fixed it). thank you for your answer though. – mostlyConfused Mar 29 '22 at 19:57
  • i followed the user1934428 's answer – mostlyConfused Mar 29 '22 at 19:59
  • @mostlyConfused from `man echo`: "echo - display a line of text" you cannot use echo to delete text from any file. – mashuptwice Mar 29 '22 at 22:11
0

Since I broke my path while tweaking things in my .zshrc, I could not enable "show hidden files" with the terminal command. Here are the steps I took:

  1. Download an IDE of your choosing (VS Code, Atom, Sublime, etc)
  2. Open Finder and navigate to your user (you can right click the folder name at the top to get a dropdown of your current folder and it's parents)
  3. Press⌘⇧.(Command-Shift-Dot) to show hidden files.
  4. Right click your .zshrc file and select "Open With"
  5. Choose your IDE/editor
  6. Make your changes and save
DroidClicketyClacker
  • 2,057
  • 1
  • 10
  • 10