Error with gradlew: /usr/bin/env: bash: No such file or directory
The problem's cause was that Git on Windows converted the line endings of gradlew
from Unix style (LF) to Windows style (CRLF).
You can turn off that automatic conversion using git config core.autocrlf false
.
Setting the line endings of gradlew
back to Unix style fixed the problem. In Vim this is done using :set fileformat=unix
.
env: bash\r: No such file or directory
The error message suggests that the script you're invoking has embedded \r
characters, which in turn suggests that it has Windows-style \r\n
line endings instead of the \n
-only line endings bash
expects.
As a quick fix, you can remove the \r
chars. as follows:
sed $'s/\r$//' ./install.sh > ./install.Unix.sh
Note: The $'...'
string is an ANSI-C quoted string supported in bash
, ksh
, and zsh
. It is used to ensure that the \r
expands to an actual CR character before sed
sees the script, because not all sed
implementations themselves support \r
as an escape sequence.
and then run
./install.Unix.sh --clang-completer
However, the larger question is why you've ended up with \r\n
-style files - most likely, other files are affected, too.
Perhaps you're running Git on Windows, where a typical configuration is to convert Unix-style \n
-only line breaks to Windows-style \r\n
line breaks on checking files out and re-converting to \n
-only line breaks on committing.
While this makes sense for development on Windows, it gets in the way of installation scenarios like these.
To make Git check out files with Unix-style file endings on Windows - at least temporarily - use:
git config --global core.autocrlf false
Then run your installation commands involving git clone
again.
To restore Git's behavior later, run git config --global core.autocrlf true
.
/usr/bin/env: 'sh': Not a directory error on Azure Devops Pipeline
I could solve the problem. I just set a new repository with the pipeline, now everything works. I think, it was a problem with my old repo.
gradlew is not found (No such file or directory)
gradlew
script is so-called Gradle wrapper, a self-contained script which allows people to run Gradle tasks without gradle installed. However it doesn't have to exist to execute Gradle tasks, it's absolutely optional.
You can generate Wrapper in your project by executing the task
gradle wrapper
Afterward, you can use ./gradlew
script instead of gradle
from PATH
To specify a Gradle version use --gradle-version on the command-line.
Just execute the command:
gradle wrapper --gradle-version <your gradle version>
Take a look here for more exhaustive and comprehensive explanation: https://docs.gradle.org/current/userguide/gradle_wrapper.html
When I type Anything in Ubuntu it returns /usr/bin/env: ‘bash\r’: No such file or directory
You have created an executable shell script with a shebang line #!/usr/bin/env bash
. But you have likely created it on Microsoft Windows, and the line endings are \r\n (i.e. CRLF), instead of \n (LF) on Linux.
This does not work with shell scripts: you have to change the line endings to \n (Notepad++ can do that, for instance). What happens is, Linux reads lines separated by \n, so the first line ends with bash\r, and this is not the name of a known executable.
Note: this will fail not only with bash, but any script using a shebang: that can be Perl, Python, R, etc. That's because whatever the programming language, the executable is not called, because it's not found.
Note also that those programming languages usually read happily files with \r\n line endings. It's really the shebang line (i.e. executable scripts) that causes this problem.
Related Topics
Pipe Output to Use as the Search Specification for Grep on Linux
How to Get the First Column of Comm Output
Cmake Doesn't Know Where Is Qt4 Qmake
Bash: Add String to the End of the File Without Line Break
Stripping Single and Double Quotes in a String Using Bash/Standard Linux Commands Only
Understanding Bash Short-Circuiting
Bash File Is Running Fine in Windows for Testng But It Is Not Working in Linux/Mac
Why Does This Code Crash with Address Randomization On
Doesn't Sh Support Process Substitution <(...)
In Order to Write Pci Ethernet Driver. How to Implement Mmap in the Pci Ethernet Driver
Importing Shapefiles in Postgresql in Linux Using Pgadmin 4
Allocate Writable Memory in the .Text Section
How to Get a List of All Valid Ip Addresses in a Local Network
How to Convert Spaces to Tabs in Vim or Linux
How to List the Contents of a Package Using Yum
How to Send Data to Local Clipboard from a Remote Ssh Session
Run a Shell Script from Docker-Compose Command, Inside the Container