How to fix Rails's warning messages with Ruby 2.7.0

前端 未结 4 1383
醉梦人生
醉梦人生 2021-02-02 05:33

Did anyone resolve this issue with Ruby 2.7.0?

I used rbenv and installed Ruby v2.7.0 and then created a Rails project using Rails v6.0.2

4条回答
  •  伪装坚强ぢ
    2021-02-02 06:24

    To suppress warnings like:

    warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call

    For now, simply prefix/pass the RUBYOPT environment variable to your rails commands:

    RUBYOPT='-W:no-deprecated -W:no-experimental' rails server
    or
    RUBYOPT='-W:no-deprecated -W:no-experimental' rails db:migrate

    This may not work with earlier versions of ruby.

    For backward compatibility with earlier versions of ruby prefix it with RUBYOPT='-W0' instead.

    example:

    RUBYOPT='-W0' bundle exec rspec

    If you don't want to prefix this each time you run a command, then simply add this to the last line of your .zshrc or .bashrc (whatever you're using):

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

    Also see last point of the notes here:
    https://rubyreferences.github.io/rubychanges/2.7.html#warning-and-

提交回复
热议问题