env: ruby\r: No such file or directory

本文介绍了解决在Unix/Mac环境下使用Git时遇到的错误——不正确的行结束符的方法。通过设置正确的行结束符配置,并利用dos2unix工具批量转换文件,可以有效修复此错误,确保代码的一致性和Git的正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

If you are working on a Unix / Mac, then this error is because you have the incorrect line endings.

here are some steps to correct.

  1. Set your line endings correctly, and have git manage how it handles them.

    $ git config --global core.autocrlf input

     

Then, in your directory, you are going to basically convert all of the files.

  1. Now you have to run the following

    $ find ./ -type f -exec dos2unix {} \;

     

This will cycle through all of your files, and convert them. This will solve the error. Add your changes. Commit them, and you should be good to go.


For those of you who got "find: ‘dos2unix’: No such file or directory" error: sudo apt install dos2unix – RealMan Jul 26 '17 at 14:59

  • Note that that find command may be excessive... this point is arguable; it may well be fine, but it may be overkill in some situations. Another possible route (for step 2 in this answer) is git rm -r --cached . followed by git reset --hard HEAD... which is likely faster (if nothing else, it won't run dos2unix on files in the .git housekeeping directory!)... This has potential gotchas as well (probably quite fine if you're running from a "clean" checkout, though), but thought I'd at least mention it. – lindes Jul 13 '19 at 0:42

Link of this question

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值