48

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 ?

Mandar Pande
  • 11,401
  • 15
  • 43
  • 70
Ritesh Mehandiratta
  • 7,061
  • 30
  • 121
  • 188

9 Answers9

97

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]
Babatunde Adeyemi
  • 14,032
  • 3
  • 33
  • 26
  • 7
    This is the solution. I copied over the file from a windows machine. Installing and running dos2unix on the file enabled it to run without issues. – johnny Jul 06 '16 at 10:57
  • If on macOS, you won't have dos2unix by default but see https://stackoverflow.com/a/23831111/31629 for a solution. – Ken Sep 14 '18 at 22:56
16

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

Laloi
  • 429
  • 4
  • 11
2

$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.

Mingyu
  • 29,163
  • 13
  • 53
  • 59
1

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
Bird87 ZA
  • 2,259
  • 8
  • 34
  • 64
Ritesh Mehandiratta
  • 7,061
  • 30
  • 121
  • 188
1

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.

Paul
  • 353
  • 2
  • 12
0

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.

Janac Meena
  • 2,505
  • 24
  • 29
0

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".

Bouke Versteegh
  • 3,280
  • 34
  • 30
0

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

Laurent
  • 164
  • 1
  • 4
  • 7
-1

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
  • 1
    You should not need to `export` anything more than once, and `PATH` will already have been `export`ed by your shell. – tripleee Jun 22 '21 at 10:43
  • i was using react-native and the official doc say that https://reactnative.dev/docs/environment-setup – Aditya parmar Jul 11 '21 at 03:46