This is a line endings issue, but not from Ubuntu. Make sure you do have node and npm installed correctly by using the command:
sudo apt install nodejs npm
Then stop Windows path variables being shared with WSL by editing the /etc/wsl.conf file in WSL. If the file doesn't exist, execute sudo touch /etc/wsl.conf first. Edit the file with the command sudo nano /etc/wsl.conf and add the following configuration:
# Wsl.conf
[interop]
appendWindowsPath = false
Then restart WSL2 with command wsl --shutdown in Windows(Powershell or CMD).
# The error message suggests that the script you're invoking has embedded
characters,
# which in turn suggests that it has Windows-style
line endings instead of the
-only
# line endings bash expects.
# As a quick fix, you can remove the
chars. as follows:
sed $'s/
$//' ./install.sh > ./install.Unix.sh
Go inside android directory and run:
dos2unix ./gradlew
<!--If you are working on a Unix based system like Ubuntu/Mac, then this error is because you have incorrect line endings.
Set your line endings correctly, and have git manage how it handles them:-->
git config --global core.autocrlf input
<!--In your work directory convert all of the files by running:-->
find ./ -type f -exec dos2unix {} ;
Docker on Windows: /usr/bin/env: bash
No such file or directory
Getting the following error when you want to start your Docker container on Windows: /usr/bin/env: bash
: No such file or directory
[edit]
I discovered that another fix is to do dos2unix <file>
dos2unix <file with the issues>
Try that if you’re on Windows or working with others who work on Windows.
[/edit]
I found several topics with several fixes. But what fixed it for me was:
Solution: Setting the line-endings correctly
In my editor:
In git: git config --global core.autocrlf false
I chose the
line ending as this is stated in PSR-12: 2.2 Files:
All PHP files MUST use the Unix LF (linefeed) line ending only.
I use PHPStorm and had to go to
Settings > Editor > Code Style > tab General > Unix and macOS (
)
NOTE: you may have to do the following to fix files with the wrong line-endings:
remove the built Docker image on Windows: first list docker images and then delete: docker rmi <imagename>
fix the line-ending of the file. You might do that by removing the newline and adding a new one. Don’t forget to save, commit and push
sed $'s/
$//' ./install.sh > ./install.Unix.sh