env:bash \r:没有这样的文件或目录 [英] env: bash\r: No such file or directory

查看:134
本文介绍了env:bash \r:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从这里安装YouCompleteMe。



执行时:

  ./install.sh --clang-completer 

我得到这个错误:

  env:bash \r:没有这样的文件或目录

我没有知道什么是环境变量的错误。这是我的bash路径:

 哪个bash 
/ bin / bash

我需要将其更改为/ usr / bash吗?如果是,那我该怎么做?我尝试更改〜/ .bashrc文件,但它不起作用。

解决方案

错误消息表明您调用的脚本嵌入了 \r 字符,这反过来表明它具有 Windows样式 \r\\\
行尾
而不是 \\\
- 仅限行结尾 bash 期望。



作为快速修复,您可以移除 \ r 字符。如下所示:

  sed $'s / \r $ //'./install.sh> ./install.Unix.sh 

然后运行

  ./ install.Unix.sh --clang-completer 


$ b $然而,更大的问题是,为什么最终会出现 \r\\\
风格的文件 - 很可能其他文件也会受到影响。 您可能正在Windows上运行 Git ,其中典型配置是将Unix风格的 \\\
- 仅对Windows样式换行符 \r\\\
检出文件时换行符并重新转换为 \\\
- 仅在提交
时换行符。



尽管这个在Windows上适用于开发 ,但妨碍了安装场景


$ b 使Git在Windows上使用Unix风格的文件结尾检出文件 - 至少暂时 - 使用:

  git config --global core.autocrlf false 

然后运行您的安装命令,其中涉及 git clone 再次。



稍后恢复Git的行为,运行 git config --global core.autocrlf true


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.

解决方案

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.

这篇关于env:bash \r:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆