1

I upgraded my ruby version from 2.7.2 to 2.7.4 using rvm install 2.7.4 and now when i try to run ruby i get the following

bash: /usr/bin/rails: /usr/bin/ruby: bad interpreter: No such file or directory

my ruby path is

> which ruby
/usr/share/rvm/ruby-2.7.4/bin/ruby

so i tried adding the path with

export PATH=/usr/share/rvm/ruby-2.7.4/bin/ruby

but i think im missing something, was hoping i could get some guidance, much appreciated

EDIT: printenv | grep rvm

rvm_delete_flag=0
rvm_prefix=/usr/share
GVM_PATH_BACKUP=/root/.gvm/bin:/usr/share/rvm/gems/ruby-2.7.4/bin:/usr/share/rvm/gems/ruby-2.7.4@global/bin:/usr/share/rvm/rubies/ruby-2.7.4/bin:/usr/share/rvm/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.gvm/pkgsets/go1.14/global/bin:/root/.gvm/gos/go1.14/bin:/root/.gvm/pkgsets/go1.14/global/overlay/bin:/root/.gvm/bin:/root/.gvm/bin:/root/.vscode-server/bin/f80445acd5a3dadef24aa209168452a3d97cc326/bin/remote-cli:/root/.rbenv/shims:/root/.rbenv/bin:/root/.gvm/pkgsets/go1.14/global/bin:/root/.gvm/gos/go1.14/bin:/root/.gvm/pkgsets/go1.14/global/overlay/bin:/root/.gvm/bin:/root/.gvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/local/go/bin:/usr/local/go/bin
MY_RUBY_HOME=/usr/share/rvm/rubies/ruby-2.7.4
rvm_version=1.29.12-next (master)
rvm_bin_path=/usr/share/rvm/bin
GEM_PATH=/usr/share/rvm/gems/ruby-2.7.4:/usr/share/rvm/gems/ruby-2.7.4@global
GEM_HOME=/usr/share/rvm/gems/ruby-2.7.4
rvm_ruby_string=ruby-2.7.4
PATH=/usr/share/rvm/gems/ruby-2.7.4/bin:/usr/share/rvm/gems/ruby-2.7.4@global/bin:/usr/share/rvm/rubies/ruby-2.7.4/bin:/usr/share/rvm/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.gvm/pkgsets/go1.14/global/bin:/root/.gvm/gos/go1.14/bin:/root/.gvm/pkgsets/go1.14/global/overlay/bin:/root/.gvm/bin:/root/.gvm/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.gvm/pkgsets/go1.14/global/bin:/root/.gvm/gos/go1.14/bin:/root/.gvm/pkgsets/go1.14/global/overlay/bin:/root/.gvm/bin:/root/.gvm/bin:/root/.vscode-server/bin/f80445acd5a3dadef24aa209168452a3d97cc326/bin/remote-cli:/root/.rbenv/shims:/root/.rbenv/bin:/root/.gvm/pkgsets/go1.14/global/bin:/root/.gvm/gos/go1.14/bin:/root/.gvm/pkgsets/go1.14/global/overlay/bin:/root/.gvm/bin:/root/.gvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/go/bin
IRBRC=/usr/share/rvm/rubies/ruby-2.7.4/.irbrc
rvm_path=/usr/share/rvm
code4fun
  • 11
  • 3
  • have you tried checking after restarting terminal? – Chandan Feb 20 '22 at 05:07
  • @Chandan yes after i restarted I still get the same error message – code4fun Feb 20 '22 at 05:14
  • please can you add the output of this command `printenv | grep rvm` in your question – Chandan Feb 20 '22 at 05:20
  • editted the post with output @Chandan – code4fun Feb 20 '22 at 05:27
  • have you added path for `rails` and `ruby` in your startup script `.bashrc` which seems to be pointing wrong – Chandan Feb 20 '22 at 05:34
  • how do i add path for rails and ruby ? the path for rails is ```usr/bin/rails``` so would it just be ```export PATH=usr/bin/rails``` ? @Chandan – code4fun Feb 20 '22 at 05:37
  • make sure you have the `rvm/script` source in your `.bashrc`, you don't have to add path in your `.bashrc` it will be taken care by `rvm` just make sure you haven't created path for `ruby` and `rails` in your startup script file – Chandan Feb 20 '22 at 05:38
  • @code4run which command you run that cause the specific error in your terminal – Chandan Feb 20 '22 at 05:41
  • okay so I added ```source /usr/share/rvm/scripts/rvm``` to my .bashrc and restarted but still no luck ? is this what you meant ? @Chandan – code4fun Feb 20 '22 at 05:52
  • please check this [post](https://stackoverflow.com/a/4911570/14475852). – Chandan Feb 20 '22 at 05:56
  • so I tried going through the feed and unfortunately none of the comments were able to help in my situation, ive decided to go back to 2.7.2 for now since that version works for me thank you for your help @Chandan – code4fun Feb 20 '22 at 06:20
  • I think you need to reinstall the Rails gem. Since RVM is before everything else in your PATH, `rails` should have been picked up from the RVM repository first if installed correctly. The fact that the `rails` commans was picked up from `/usr/bin`, means `rails` was missing from your RVM repository. It's as simple as that. The shell follows `PATH` when it looks up binaries. There is no additional magic going on. If `rails` comes from `/usr/bin`, it means it does not exist in the other folders in `PATH`. – Casper Feb 20 '22 at 10:38

0 Answers0