I installed Ruby 1.9.2 from source and was using it for a while but now I wanted to start using RVM, so I uninstalled my source Ruby 1.9.2 installation and installed ruby using sudo apt-get install ruby. However, now when I run ruby --version I get:
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt-get install ruby
When I call which ruby I get nothing. My /etc/environment (which I’ve sourced) contains:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin:/usr/games:/usr/bin"
When I run sudo apt-get install ruby it says that it’s already installed. When I ls /usr/bin, ruby appears but it’s in red (not sure what that means). If I cd /usr/bin/ruby or less /usr/bin/ruby it gives me a “No such file or directory”
When I run dpkg -L ruby it gives me:
/.
/usr
/usr/bin
/usr/share
/usr/share/doc
/usr/share/doc/ruby
/usr/share/doc/ruby/changelog.gz
/usr/share/doc/ruby/ruby-policy.html
/usr/share/doc/ruby/ruby-policy.html/index.html
/usr/share/doc/ruby/ruby-policy.html/ch-ruby.html
/usr/share/doc/ruby/ruby-policy.html/ch-module_packages.html
/usr/share/doc/ruby/ruby-policy.html/ch-programs.html
/usr/share/doc/ruby/ruby-policy.html/ap-build_dependencies.html
/usr/share/doc/ruby/ruby-policy.html/ap-ruby1.8_bundled_modules.html
/usr/share/doc/ruby/ruby-policy.html/ap-transition_1.6_to_1.8.html
/usr/share/doc/ruby/README.Debian
/usr/share/doc/ruby/copyright
/usr/share/doc/ruby/ruby-policy.txt.gz
/usr/share/doc/ruby/ruby-policy.sgml.gz
/usr/share/man
/usr/share/man/man1
/usr/bin/testrb
/usr/bin/erb
/usr/bin/ruby
/usr/share/man/man1/testrb.1.gz
/usr/share/man/man1/erb.1.gz
/usr/share/man/man1/ruby.1.gz
…so it’s definitely installing to /usr/bin/ruby
It seems like Ruby is installed, but bash can’t find it because something is wrong with /usr/bin/ruby. Any ideas how to fix this?
It sounds like
/usr/bin/rubyis a symbolic link, whose target has been deleted.If you type the command
ls -l /usr/bin/ruby, that will display info about the file in long format. If it is a symbolic link, then the target of the link will be shown. This what what that command shows for me (I’m on OS X):Assuming it is a symbolic link, go to the target of the link and see if that file exists. I’m guessing that it doesn’t, and the ruby installation script only checks for the existence of /usr/bin/ruby to determine if ruby is installed or not. If you delete
/usr/bin/rubythis will hopefully fix the issue.