3

I am trying to run a ruby program and I get bash: /usr/bin/ruby: No such file or directory When I navigate to /usr/bin/ruby and ls | grep ruby I get an output with ruby in it. When I try to ./ruby I STILL get bash: ./ruby: No such file or directory. I have tried uninstalling and reinstalling ruby to no avail.

Does anyone have any idea what could be going on? I am really stumped.

4

4 Answers 4

4

Just adding a different possible cause and fix for the same /usr/bin/ruby: No such file or directory error after installing 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/ruby but look for it at /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/ruby that points to /usr/local/bin/ruby.

3

Per the comments on the question, your /usr/bin/ruby binary is a symlink to /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/ruby to 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.

6
  • 1
    ls -la /etc/alternatives/ruby gives me lrwxrwxrwx 1 root root 18 Aug 12 20:11 /etc/alternatives/ruby -> /usr/bin/ruby1.9.1
    – M1Reeder
    Sep 14, 2013 at 22:49
  • 1
    I am basically just advocating that you continue to trace the path of symlinks here, until you get to the REAL binary (or else until you reach a path that does not exist). So, does ls -la /usr/bin/ruby1.9.1 show a real binary at that path? Rinse, repeat...
    – Stuart M
    Sep 14, 2013 at 22:50
  • YES ls -la /usr/bin/ruby1.9.1 gives me -rwxr-xr-x 1 root root 10281 Sep 3 23:16 /usr/bin/ruby1.9.1 BUT ./ruby1.9.1 still gives me a no such file error
    – M1Reeder
    Sep 14, 2013 at 22:52
  • What happens when you run /usr/bin/ruby1.9.1 -v?
    – Stuart M
    Sep 14, 2013 at 22:53
  • bash: /usr/bin/ruby1.9.1: No such file or directory
    – M1Reeder
    Sep 14, 2013 at 22:54
3

The better option is use

#!/usr/bin/env ruby

it will always use current selected ruby in the environment, not depending on any tool

-2

I had this error while working on Ruby on rails project and deployment to 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.