'getting error /usr/bin/env: sh: No such file or directory when running command play

I am a beginner on Play framework . I just extract Play framework files and extracted them and gave the path of play directory in $PATH global variable. After this when I run the the command on ubuntu play help, its giving me below error:

/usr/bin/env: sh: No such file or directory

Any clue why I am facing this error and how to resolve it ?



Solution 1:[1]

This error usually happens if the script has windows line endings instead of unix line endings.

Try running dos2unix on the script and try running your command again to see if you get the same error.

dos2unix [filename]

Solution 2:[2]

I had the same problem, and resolved it using Notepad++, by clicking Edit -> EOL Conversion -> Unix and then save the file.

Solution 3:[3]

$PATH environment variable is set in ~/.bashrc, ~/.bash_profile or ~/.profile.

source the relevant configuration file or start a new bash terminal should solve the problem.

Solution 4:[4]

Just change the sh terminal to bash using this link and everything should be fine.

1. Change user entry in /etc/passwd
a) edit /etc/passwd using any editor

$ vi /etc/passwd
b) find the line that belongs to the user (foo) that we about to modify
foo:x:1001:1001::/home/foo:/bin/sh
c) change from /bin/sh to /bin/bash
foo:x:1001:1001::/home/foo:/bin/bash
d) save
e) Logout and login back

2. Use chsh command
a) type chsh
$ chsh
b) You will be asked for password. Enter your password
c) This screen will appear
Enter the new value, or press ENTER for the default
Login Shell [/bin/sh]:
d) Put /bin/bash at the menu and press Enter

Solution 5:[5]

I had the same error. I am using Windows Subsystem for Linux. First I tried removing the Windows Lineendings by entering tr -d '\r' < input.sh > output.sh. This did not help in fact the path actually did not exist instead of #!/usr/bin/env bash I needed to use #!/usr/bin/bash in the first line of my script.

Solution 6:[6]

Got this error when running on new Macbook Pro, because the default shell is now ZSH instead of Bash. Just type bash to enter bash shell, and run your script as normal.

Solution 7:[7]

This can also happen if your file is UTF-8 encoded with a "BOM" header (byte-order-mark) at the beginning of the file. Use your editor to "remove bom".

Solution 8:[8]

For peoples in Windows using Visual Studio Git module, if you encounter this error

enter image description here

You should setup C:\Program Files\Git\bin for Path in Environment Variables System

enter image description here

Solution 9:[9]

i was getting slimier error in react-native because i forgot to add environment variable for android studio

add in .bashrc

`export ANDROID_HOME=$HOME/Android/Sdk
 export PATH=$PATH:$ANDROID_HOME/emulator
 export PATH=$PATH:$ANDROID_HOME/tools
 export PATH=$PATH:$ANDROID_HOME/tools/bin
 export PATH=$PATH:$ANDROID_HOME/platform-tools

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Babatunde Adeyemi
Solution 2 Laloi
Solution 3 Mingyu
Solution 4 Bird87 ZA
Solution 5 Paul
Solution 6 Janac Meena
Solution 7 Bouke Versteegh
Solution 8 Laurent
Solution 9 Aditya parmar