ubuntu-wsl2-systemd-script.sh: line 2: $'\r': command not found
andraspatka opened this issue · comments
The scripts are using windows line breaks (CRLF) instead of unix line breaks (LF). This causes some weird errors:
bash ubuntu-wsl2-systemd-script.sh
Error:
ubuntu-wsl2-systemd-script.sh: line 2: $'\r': command not found
ubuntu-wsl2-systemd-script.sh: line 18: syntax error near unexpected token `$'{\r''
'buntu-wsl2-systemd-script.sh: line 18: `function interop_prefix {
Solution is to convert the windows line breaks to unix line breaks. The easiest way to achieve this is to use a text editor such as VS Code or Notepad++.
System: Ubuntu 18.04 LTS
Where should I change the lines?
The easiest way to do this is to use a text editor like Notepad++, VSC, Intellij, etc. In most cases on the bottom right part of the editor you can see the line endings of the file (LF, CRLF, etc.). The aim is to change it so that it is on LF (Unix style) and then save the file.
Alternatively, you may use a tool that removes the \r character from the file. Haven't tested it, but that should work as well.