DEV Community

Cover image for Suppressing Ruby 2.7.0 warnings in RubyMine and zsh/bash
Ruslan Kornev
Ruslan Kornev

Posted on

Suppressing Ruby 2.7.0 warnings in RubyMine and zsh/bash

Hi all. If you've already decided to use Ruby 2.7.0 you may struggle with warnings like this one:

/Users/r.kornev/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.2/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/r.kornev/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.2/lib/action_dispatch/middleware/static.rb:110: warning: The called method `initialize' is defined here
Running via Spring preloader in process 1224
Loading development environment (Rails 6.0.2.2)
irb(main):001:0> Post.first
   (6.7ms)  SELECT sqlite_version(*)
  Post Load (0.1ms)  SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT ?  [["LIMIT", 1]]
/Users/r.kornev/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-6.0.2.2/lib/active_model/type/integer.rb:13: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/r.kornev/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-6.0.2.2/lib/active_model/type/value.rb:8: warning: The called method `initialize' is defined here
=> nil

I didn't understand is there a way to add a global environment variable which could affect all running processes like zsh, bash, RubyMine in MacOS Catalina.

So I've decided to split solutions:

RubyMine

Open Run -> Edit configurations

Then in an appropriate configuration add RUBYOPT=-W:no-deprecated -W:no-experimental

RubyMine Ruby 2.7.0 warnings

zsh/bash

Add export RUBYOPT="-W:no-deprecated -W:no-experimental"
to ~/.zshrc or/and ~/.bashrc

That's it :)

You also may be interested in these articles:

Discussion (0)