Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

env: bash\r: No such file or directory

People also ask

What does usr bin env bash mean?

As we mentioned earlier,#!/usr/bin/env bash is also a shebang line used in script files to execute commands with the Bash shell. It uses the env command to display the environment variables present in the system and then execute commands with the defined interpreter.

Why is there no such file or directory?

log No such file or directory” the problem is most likely on the client side. In most cases, this simply indicates that the file or folder specified was a top-level item selected in the backup schedule and it did not exist at the time the backup ran.


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.


>vim gradlew
:set fileformat=unix
:wq
>./gradlew clean build

As the above comments say, it is happening due to windows line endings. To fix the issue follow these steps

For MAC:

brew install dos2unix # Installs dos2unix Mac
find . -type f -exec dos2unix {} \; # recursively removes windows related stuff

For Linux:

sudo apt-get install -y dos2unix # Installs dos2unix Linux
sudo find . -type f -exec dos2unix {} \; # recursively removes windows related stuff

And make sure your git config is set as follows:

git config --global core.autocrlf input

Your file has Windows line endings. Change to Unix line endings.


Ran into something similar. You can use dos2unix install.sh to convert the line endings. Multiple files via find [pattern] | xargs dos2unix


Quick command for converting line ending:

dos2unix thescript.sh

In my case I had a wrong git configuration. The git documentation states:

If you’re programming on Windows and working with people who are not (or vice-versa), you’ll probably run into line-ending issues at some point

I'm using Mac OS and I exactly have this issue in one of my projects. To solve it I turned autocrlf to true which was wrong.

You can check the autocrlf state of your git configuration like this:

git config core.autocrlf

So if this returns true and the problem occurs within a git repository you'll have to change that configuration to

git config --global core.autocrlf input

on a Mac / Unix system. For Windows only projects you can use

git config --global core.autocrlf false

In my case I deleted the git repository and cloned it again and after that everything worked again as expected.

Find out more at https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration