2

After installing Ruby 2.7.0 running specs has become a nightmare of warnings such as this one:

/Users/user/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capybara-3.30.0/lib/capybara/node/matchers.rb:835: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/user/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capybara-3.30.0/lib/capybara/node/matchers.rb:861: warning: The called method `_set_query_session_options' is defined here

Since these warnings are popping out of gems, they really aren't helping and making RSpec output a total mess.

I have tried adding this line to the spec_helper.rb

config.warnings = false

And this line to config/environments/test.rb

config.active_support.deprecation = :log

But yet, the warnings still pop up by the hundreds. Is there anything I can do to be rid of them?

Running Ruby on Rails 6.0.2.1 and Ruby 2.7.0

NOTE It has been suggested that the answer to this question already exists in Suppress Ruby warnings when running specs This looks like a similar question, but the solution provided has no effect. I see all of the warnings.

Carl
  • 1,246
  • 3
  • 21
  • 39
  • Possible duplicate of [Suppress Ruby warnings when running specs](https://stackoverflow.com/questions/5591509/suppress-ruby-warnings-when-running-specs) – anothermh Jan 11 '20 at 19:56
  • The answers provided there don't work for me for whatever reason @anothermh – Carl Jan 11 '20 at 20:33

1 Answers1

7

These warnings/deprecations are directly from the ruby 2.7, you cannot silence them by rails or rspec configuration.

Ruby 2.7 is trying to warn you about backward incompatibilities that will arrive in ruby 3.0. See the release notes. Main source of deprecations is the Separation of positional and keyword arguments part.

Rails and other libraries and gems are not prepared for this change yet, so ruby is showing you tons of warnings.

I would wait with upgrade until gems resolve these warnings in the future, but you can also suppress these warnings according to following article https://prathamesh.tech/2019/12/26/managing-warnings-emitted-by-ruby-2-7/

RUBYOPT='-W:no-deprecated -W:no-experimental' rails c
edariedl
  • 3,234
  • 16
  • 19
  • Thank you. This does work. Is there a way to run this automatically? – Carl Jan 11 '20 at 20:18
  • 1
    you can `export RUBYOPT='-W:no-deprecated -W:no-experimental'` in tour rc file, to set this env permamently. – Greg Jan 12 '20 at 20:36
  • @Grzegorz Can you expound a bit on the tour rc file you referenced? – Adrian May 20 '22 at 16:19
  • Sorry: an awful typo, and I can't edit my comment :) I meant `your` RC file, like `.zshrc` or `.bashrc` (basically files that are run when your terminal starts) – Greg May 23 '22 at 07:47