Leonid Svyatov
[≡]

How to hide Ruby 2.7 deprecation warnings system-wide

· 1 min read

Are you using rbenv? Want to hide Ruby 2.7 deprecation warnings system-wide and not to deal with it on a per-project basis? This small tutorial is for you!

All you have to do is create file ~/.rbenv/rbenv.d/exec/hide-deprecations-for-2.7.bash with the following content:

# ~/.rbenv/rbenv.d/exec/hide-deprecations-for-2.7.bash

if [[ ${RBENV_VERSION%.*} == '2.7' ]]; then
  export RUBYOPT="-W:no-deprecated -W:no-experimental"
else
  unset RUBYOPT
fi

Done.

The rbenv hooks documentation explains how this works.

I’ve tested it in Zsh. It should work in Bash, but I can’t guarantee it.


share: [ x ][ bluesky ][ hn ]

Leonid Svyatov [ github ][ linkedin ][ email ]

Hotkeys