ohmyzsh/ohmyzsh

(eval):10: parse error near `^M'

iris-qq opened this issue · 3 comments

Describe the bug

企业微信截图_17155882991030
windows11+git bash+ ohmyszah+conda

企业微信截图_17155882121555
conda generate code into .zshrc
企业微信截图_17155882526898

Steps to reproduce

conda init zsh

conda activate test

Expected behavior

you can step into a env from conda

Screenshots and recordings

help

OS / Linux distribution

windows11

Zsh version

5.9

Terminal emulator

Terminal preview

If using WSL on Windows, which version of WSL

None

Additional context

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
if [ -f '/d/Softwares/anaconda3/Scripts/conda.exe' ]; then
    eval "$('/d/Softwares/anaconda3/Scripts/conda.exe' 'shell.zsh' 'hook')"
fi
# <<< conda initialize <<<

You shouldn't source zshrc, just do exec zsh or omz reload if you want to restart your shell.
That seems a situation to report to conda, it seems like oh-my-zsh is not affecting here.

yes, I had report this to conda, omz reload not effect

➜  ~ omz reload
(eval):10: parse error near `^M'
➜  ~

The issue here is that the .zshrc file has Windows line breaks (CRLF) instead of Unix line breaks (LF). The ^M character in the error corresponds to the CR (Carriage Return) character (equivalent to \r).

To prevent this, first change the .zshrc file to Unix line breaks with command dos2unix .zshrc, and any modifications you make to it make sure to save with LF line breaks.