DEV Community

Leonid Svyatov
Leonid Svyatov

Posted on

How to hide Ruby 2.7 deprecation warnings system-wide

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
Enter fullscreen mode Exit fullscreen mode

Done.

How exactly does it work can be found here.

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

Top comments (0)