无法重新安装Ruby至最新版本,终端无法识别Ruby命令求助
Hey, let's work through this Ruby issue step by step. I've run into similar problems on Debian/Ubuntu-based systems before, so here's what you can try:
First, confirm where Ruby 2.3 is actually installed
Theaptpackage manager might have installed Ruby 2.3 to a version-specific path instead of creating a genericrubyalias. Run this command to list all files from theruby2.3package:dpkg -L ruby2.3Look for a line like
/usr/bin/ruby2.3— that's the actual executable file.Create a symbolic link to make the
rubycommand work
If you found/usr/bin/ruby2.3, create a soft link from this file to/usr/bin/ruby(which is in your system's default PATH):sudo ln -s /usr/bin/ruby2.3 /usr/bin/rubyDo the same for the
gemcommand if you need it:sudo ln -s /usr/bin/gem2.3 /usr/bin/gemVerify the fix
Run these commands to check if everything works as expected:ruby --version gem --versionYou should see Ruby 2.3's version number pop up now.
If the above doesn't work, try reinstalling the packages
Sometimes the installation might have missed creating necessary links. Reinstall both the version-specific package and the genericrubymeta-package:sudo apt-get update sudo apt-get install --reinstall ruby2.3 rubyThe
rubymeta-package is supposed to point to the default Ruby version on your system, so this might automatically set up the correct links for you.Double-check your PATH (just in case)
Even thoughwhich rubyreturned nothing, confirm that/usr/binis in your PATH:echo $PATHIf
/usr/binisn't listed, you can add it temporarily withexport PATH=$PATH:/usr/bin, or permanently by adding that line to your~/.bashrcor~/.profilefile.
内容的提问来源于stack exchange,提问作者Priya

