macoszshzshrcamazon-codewhispereramazon-q-developer

Parse error near `\n' in .zshrc file after updating Amazon Q


After updating Amazon Q on my Macbook, I get an error every time I open a terminal, which looks like this:

/Users/dylan/.zshrc:24: parse error near `\n'
dylan@Dylans-MBP-2 ~ % 

When I navigate to my .zshrc file, it looks like this:

# Amazon Q post block. Keep at the bottom of this file.
[[ -f "${HOME}/Library/Application Support/amazon-q/shell/zshrc.post.zsh" ]] && builtin source "${HOME}/Library/Application Support/amazon-q/shell/zshrc.post.zsh"

The 24th line of the file is technically the newline that follows the last written line.

I tried looking for characters that it might not be able to understand. I also tried to delete the newline which then gave me the following error:

/Users/dylanravel/.zshrc:23: parse error near `"${HOME}/Library/App...'

Let me know if you guys know a fix to these errors! Thank you in advance!


Solution

  • Thank you @Gairfowl and @user1934428. You both pointed me in the correct direction!

    After you pointed out that the error could be anywhere in the file, I took your advice and went line by line, commenting out lines until the error disappeared.

    It ended up being an issue with this line:

    if which rbenv > /dev/null; then eval "$(rbenv init -)"; fieval "$(zoxide init zsh)"
    

    I successfully fixed this line by changing it to:

    if which rbenv > /dev/null; then eval "$(rbenv init -)"; eval "$(zoxide init zsh)"; fi
    

    Thank you all for your help! Have a wonderful day!