Terminal parse error

I have an error message showing up whenever I open the terminal that says:


/Users/lingchen/.zshrc:17: parse error near `then'

(base) lingchen@Lingchens-MacBook-Pro ~ % 


I tried to look for the zshrc file but couldn't find any. I can install packages through the terminal but when I try to run them, it gives an error message saying the package is not found.


I'm really at my wits' end.. help.

MacBook Pro (M1, 2020)

Posted on Dec 24, 2023 4:25 AM

Reply
Question marked as Top-ranking reply

Posted on Dec 24, 2023 6:30 AM

There is a valid reason I have no Zsh scripting syntax in my ~/.zshrc and have no syntax parsing errors.


Do this in the Terminal with each line ending in a return. We are renaming the ~/.zshrc file without the dot:


cd
mv ~/.zshrc ~/zshrc_bak


Then, copy/paste the following into the Terminal and follow it with a return:


<<"EOF" > ~/.zshrc
export PATH=".:/usr/local/bin:${PATH}"
PS1="%m: %~ %% "
EOF


That creates a new ~/.zshrc dot file with just a basic PATH and prompt PS1 statement. No computational Shell scripting involved.


If you are using homebrew as a package manager, then you want this exported PATH:


export PATH=".:/usr/local/bin:${PATH}:/opt/homebrew/bin"



You can force this into the current Terminal session with:


source ~/.zshrc


2 replies
Question marked as Top-ranking reply

Dec 24, 2023 6:30 AM in response to lingchen__

There is a valid reason I have no Zsh scripting syntax in my ~/.zshrc and have no syntax parsing errors.


Do this in the Terminal with each line ending in a return. We are renaming the ~/.zshrc file without the dot:


cd
mv ~/.zshrc ~/zshrc_bak


Then, copy/paste the following into the Terminal and follow it with a return:


<<"EOF" > ~/.zshrc
export PATH=".:/usr/local/bin:${PATH}"
PS1="%m: %~ %% "
EOF


That creates a new ~/.zshrc dot file with just a basic PATH and prompt PS1 statement. No computational Shell scripting involved.


If you are using homebrew as a package manager, then you want this exported PATH:


export PATH=".:/usr/local/bin:${PATH}:/opt/homebrew/bin"



You can force this into the current Terminal session with:


source ~/.zshrc


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal parse error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.