bash: /usr/bin/ruby: 没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18807037/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
bash: /usr/bin/ruby: No such file or directory
提问by M1Reeder
I am trying to run a ruby program and I get bash: /usr/bin/ruby: No such file or directoryWhen I navigate to /usr/bin/rubyand ls | grep rubyI get an output with rubyin it. When I try to ./rubyI STILL get bash: ./ruby: No such file or directory. I have tried uninstalling and reinstalling ruby to no avail.
我正在尝试运行一个 ruby 程序,bash: /usr/bin/ruby: No such file or directory当我导航到时/usr/bin/ruby,ls | grep ruby我得到了一个输出ruby。当我尝试时,./ruby我仍然得到bash: ./ruby: No such file or directory. 我试过卸载并重新安装 ruby 无济于事。
Does anyone have any idea what could be going on? I am really stumped.
有谁知道会发生什么?我真的很难过。
采纳答案by Stuart M
Per the comments on the question, your /usr/bin/rubybinary is a symlink to /etc/alternatives/ruby.
根据对该问题的评论,您的/usr/bin/ruby二进制文件是指向/etc/alternatives/ruby.
lrwxrwxrwx 1 root root 22 Aug 12 20:11 /usr/bin/ruby -> /etc/alternatives/ruby
You should confirm that path exists (run ls -la /etc/alternatives/rubyto check if that path exists) and if it does not, you'll need to reinstall Ruby using your system package manager (e.g., apt-get), download and install Ruby from https://www.ruby-lang.org, or use a tool like RVM.
您应该确认路径存在(运行ls -la /etc/alternatives/ruby以检查该路径是否存在),如果不存在,则需要使用系统包管理器(例如apt-get)重新安装 Ruby,从https://www.ruby下载并安装 Ruby -lang.org,或使用RVM 之类的工具。
回答by user56reinstatemonica8
Just adding a different possible cause and fix for the same /usr/bin/ruby: No such file or directoryerror after installing Ruby.
只需/usr/bin/ruby: No such file or directory在安装 Ruby 后添加不同的可能原因并修复相同的错误。
If, unlike the original poster here, you get this same message but on investigating find that there really is nothing at /usr/bin/ruby, try /usr/local/bin/ruby --version: it seems that some installations put the binary in /usr/local/bin/rubybut look for it at /usr/bin/ruby.
如果,与此处的原始海报不同,您收到相同的消息,但在调查中发现在 处确实没有任何内容/usr/bin/ruby,请尝试/usr/local/bin/ruby --version:似乎某些安装将二进制文件放入/usr/local/bin/ruby但在 处查找/usr/bin/ruby。
This happened to me with ruby version 1.9.3p547 on Centos. If this is what's happened, the easy fix is to create a symlink at /usr/bin/rubythat points to /usr/local/bin/ruby.
我在 Centos 上使用 ruby 版本 1.9.3p547 时发生了这种情况。如果发生这种情况,简单的解决方法是在/usr/bin/ruby该点创建一个符号链接到/usr/local/bin/ruby.
回答by efrenfuentes
The better option is use
更好的选择是使用
#!/usr/bin/env ruby
it will always use current selected ruby in the environment, not depending on any tool
它将始终使用环境中当前选择的 ruby,不依赖于任何工具
回答by Bryan Memeti
I had this error while working on Ruby on rails project and deployment to heroku.
我在处理 Ruby on rails 项目和部署到 heroku 时遇到了这个错误。
For ruby on rails and heroku On you editor, find 'bin' folder then in each file remove the ruby number extension leaving 'ruby' only on the commented code. Thank me later
对于 ruby on rails 和 heroku 在您的编辑器上,找到“bin”文件夹,然后在每个文件中删除 ruby 编号扩展名,仅在注释代码上留下“ruby”。晚点再谢我

