Not my solution, but this seemed to work for me. Appears that having the Windows folder structure in $PATH while using WSL2 was causing that parse error, but I’m not exactly sure why.
- Go to your user root (
cd ~) - Open
.bashrcin your chosen editor (vi, nano, etc.) - Append to the end of the file:
export PATH=$(echo "$PATH" | sed -e 's/:\/mnt[^:]*//g') # strip out problematic Windows %PATH% - Close and re-open all terminal windows
Source: https://hackmd.io/@badging/wsl2#Troubleshooting-PATH
Updated: Per Lh Lee’s comment, I’ve updated the regex from s/:\/mnt.*//g to s/:\/mnt[^:]*//g as this avoids accidentally capturing anything extra after the problematic /mnt paths.
Whereas the first regex will match /mnt/c/blah:/other/thing, the new one will not.