env: bash\r: No such file or directory

浪尽此生 提交于 2019-11-26 12:08:36

问题


I\'m trying to install YouCompleteMe from here.

When I execute:

    ./install.sh --clang-completer

I get this error:

    env: bash\\r: No such file or directory

I don\'t know whats wrong with environment variables. Here\'s my bash path:

which bash 
/bin/bash

Do I need to change it to /usr/bash? If yes, then how should I do that? I tried changing ~/.bashrc file, but it didn\'t work.


回答1:


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

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.




回答2:


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



回答3:


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




回答4:


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




回答5:


Quick command for converting line ending:

dos2unix thescript.sh


来源:https://stackoverflow.com/questions/29045140/env-bash-r-no-such-file-or-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!