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

编程入门 行业动态 更新时间:2024-10-28 12:17:14
本文介绍了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:没有这样的文件或目录

本文发布于:2023-10-26 01:00:10,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   目录   env   bash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!