0

I installed rails with "gem install rails" and it is installed properly.

But when I check rails version "rails -v". It keeps saying

/usr/bin/env: ‘ruby2.7’: No such file or directory

I've installed rails before. Maybe that's the reason? If so, how can I solve this issue? I've search other similar issues and solutions but noting solved my problem.

I'm currently using Ubuntu 20.04.2 LTS.

Sat Naing
  • 3
  • 2
  • 2
    are you using the system installed ruby, or one provided by `rvm` or `rbenv`? – Jad May 14 '21 at 09:59
  • What is the output of `which rails`? My guess, and it's only a guess, is that you have some local executable (`./bin/rails`?) that specifies `#!/usr/bin/env ruby2.7` on the first line, weirdly. Perhaps because someone - either you or another developer on the project - aliased `ruby2.7` to run that ruby version, instead of using `rbenv`/`rvm`/similar to switch versions. – Tom Lord May 14 '21 at 10:48
  • @TomLord either that, or he's calling the OS installed `rails` when ruby has been installed via `rvm` or similar ... – Jad May 14 '21 at 13:27
  • @jad I previously installed using rvm, then I use rbenv. – Sat Naing May 16 '21 at 03:29
  • @TomLord the output of which rails is ``/home/eklage/.rvm/gems/ruby-2.5.1/bin/rails`` – Sat Naing May 16 '21 at 03:31
  • @SatNaing Aha, a clue! Your `rails` command is pointing to an `rvm` folder, despite the fact that you "uninstalled rvm"? This probably means that you **DIDN'T SUCCEED FULLY REMOVING RVM**, from your system before installing `rbenv`, and now your system is in a weird state as it's muddling up the two libraries. – Tom Lord May 16 '21 at 15:15
  • Solution: Remove `rvm` completely. https://stackoverflow.com/a/3558763/1954610 – Tom Lord May 16 '21 at 15:16
  • @TomLord, somehow it works! :D As you said, I removed rvm completely. But it still showing the previous error. So, I also remove ruby, login my computer again, and install those all again only using rbenv. In this way, it works. Thanks a lot! – Sat Naing May 16 '21 at 17:36
  • @SatNaing That's probably because your `$PATH` variable was messed up, and by restarting your computer, you also reset this variable. – Tom Lord May 16 '21 at 17:51

0 Answers0