0

I have a situation where

rbenv global
2.7.1

But

ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]

I've tried rbenv rehash, but it didn't seem to alter anything.

How do I get the default global version of ruby to be 2.7.1 ?

stevec
  • 41,291
  • 27
  • 223
  • 311

2 Answers2

1

Is the environment variable RBENV_VERSION set to anything? I second what stevec said, but also keep in mind that the version will also be set to the value of RBENV_VERSION, which you may have set for your current session if you ran ruby shell VERSION_NUM. RBENV_VERSION takes precedence over all else: stackoverflow.com/a/12150580

jajavoli
  • 63
  • 2
  • 7
0

This is probably a terrible answer that doesn't show a full understanding of the situation, but what worked for me was:

  • if using zsh, any Stack Overflow answers saying to do something to bash files should instead be done to zsh files - i.e. inspect these files ~/.zshenv and ~/.zshrc (not their bash equivalents)
  • I then corrected for this problem - that is, commented out the first line

The closed and reopened zsh (terminal) and suddenly ruby -v returned the desired 2.7.1

Note: there was another problem, outside my app, ruby -v was 2.7.1, but inside the app directly, it was still returning 2.5.1, that was due to a file called .ruby-version, which needed to be updated. Now that I look back on this problem, I think that was the only problem

stevec
  • 41,291
  • 27
  • 223
  • 311