0
Mac OS

I was working with Ruby 2.7.0 and Rails 6, but a few gems, as well as dependencies, are not Ruby 2.7.0 compliant, and was getting a ton of warning messages. So, I decided to un-install Ruby 2.7.0

rbenv uninstall 2.7.0

rbenv install 2.6.3

Now, whenever I try to do anything, I get the following error message:

ruby: invalid option -:  (-h will show valid options) (RuntimeError)

Even if I'm doing something as simple as:

ruby -v

From my terminal:

unset RUBYOPT

Everything works fine, until the next time I go into terminal. While I may be able to work around it, on my development machine, from terminal, my IDE doesn't understand this, and generated the same error, whenever I do Rake, from the IDE.

When I set rbenv up, it inserted the following, into my .bash_profile:

export RUBYOPT='-W:no-deprecated -W:no-experimental'
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

Any ideas?

Solution:

I removed the following statement, that was added by rbenv to my .bash_profile:

export RUBYOPT='-W:no-deprecated -W:no-experimental'

and it's working fine now

EastsideDev
  • 6,257
  • 9
  • 59
  • 116
  • 1
    Are you setting RUBYOPT somewhere in your shell initialization like in your `~/.bash_profile` or `~/.profile`? – max Apr 07 '20 at 17:05
  • Yes, it looks like rbenv inserted a couple of lines into .bash_profile, see edit to my question – EastsideDev Apr 07 '20 at 17:33
  • 1
    You should be able to just comment out that line. `'-W:no-deprecated -W:no-experimental'` just silences a bunch of depreciation messages. – max Apr 07 '20 at 17:43
  • Also in OS-X GUI programs like your IDE don't get their ENV vars from your shell. `unset RUBYOPT` just effects that shell. Not the whole OS. https://stackoverflow.com/questions/135688/setting-environment-variables-on-os-x – max Apr 07 '20 at 17:48
  • It does kind of sound like either a bug in rbenv or something else on your system thats modifying RUBYOPT. When you launch a shell does `echo $RUBYOPT` output `-`? – max Apr 07 '20 at 18:05
  • Isn't '-W:no-deprecated -W:no-experimental' what's preventing the deprecation messages? I don't get deprecation messages on my local system, I get them on the server, but that's not really what my question is. It's about resetting RUBYOPT once and for all. – EastsideDev Apr 07 '20 at 18:06
  • When I echo $RUBYOPT, I get: -W:no-deprecated -W:no-experimental, which is the setting in .bash_profile – EastsideDev Apr 07 '20 at 18:07
  • Tip: You don't need to uninstall Ruby, you can just switch versions. That's what `rbenv` is all about. – tadman Apr 07 '20 at 20:03

0 Answers0