我正在尝试 运行 rake 测试 ruby / sinatra,它告诉我 rake 中止了!我不知道该怎么办
I'm trying to run a rake test ruby / sinatra and its telling me rake aborted! I'm not sure what to do
这是我的终端显示的内容..
user@Users-MacBook-Pro palindrome_app % bundle exec rake test
/Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mustermann-1.1.1/lib/mustermann.rb:73:in `new': Hash can't be coerced into Mustermann::Pattern (TypeError)
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mustermann-1.1.1/lib/mustermann.rb:70:in `block in new'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mustermann-1.1.1/lib/mustermann.rb:70:in `map'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mustermann-1.1.1/lib/mustermann.rb:70:in `new'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1641:in `compile'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1629:in `compile!'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1271:in `error'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1839:in `<class:Base>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:894:in `<module:Sinatra>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:22:in `<top (required)>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/main.rb:1:in `require'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/main.rb:1:in `<top (required)>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra.rb:1:in `require'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra.rb:1:in `<top (required)>'
from /Users/user/Desktop/repos/palindrome_app/app.rb:1:in `require'
from /Users/user/Desktop/repos/palindrome_app/app.rb:1:in `<top (required)>'
from /Users/user/Desktop/repos/palindrome_app/test/test_helper.rb:3:in `require_relative'
from /Users/user/Desktop/repos/palindrome_app/test/test_helper.rb:3:in `<top (required)>'
from /Users/user/Desktop/repos/palindrome_app/test/site_pages_test.rb:1:in `require_relative'
from /Users/user/Desktop/repos/palindrome_app/test/site_pages_test.rb:1:in `<top (required)>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_test_loader.rb:17:in `require'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_test_loader.rb:17:in `block in <main>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_test_loader.rb:5:in `select'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_test_loader.rb:5:in `<main>'
rake aborted!
Command failed with status (1)
/Users/user/.rbenv/versions/3.0.0/bin/bundle:23:in `load'
/Users/user/.rbenv/versions/3.0.0/bin/bundle:23:in `<main>'
Tasks: TOP => test
(See full trace by running task with --trace)
tl;dr:将 sinatra
升级到版本 2.1.0
。(或者,将 ruby 降级到 v2.7
。)
您是运行宁旧gem版本(特别是sinatra v2.0.3
),最新 版本 ruby (v3.0.0
)。这样做可能会 运行 遇到各种兼容性问题,因为您可能会丢失来自这些库的关键 ruby 3.0 兼容性更新。
sinatra
变更日志中有 various mentions 个 ruby 2.7+ 关键字弃用修复。
具体来说,这个错误:
gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1629:in `compile!'
已由 this change in this PR, which shipped as part of sinatra v2.0.8
. Also, additional fixes 修复,已作为 v2.1.0
版本的一部分添加。
这是我的终端显示的内容..
user@Users-MacBook-Pro palindrome_app % bundle exec rake test
/Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mustermann-1.1.1/lib/mustermann.rb:73:in `new': Hash can't be coerced into Mustermann::Pattern (TypeError)
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mustermann-1.1.1/lib/mustermann.rb:70:in `block in new'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mustermann-1.1.1/lib/mustermann.rb:70:in `map'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mustermann-1.1.1/lib/mustermann.rb:70:in `new'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1641:in `compile'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1629:in `compile!'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1271:in `error'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1839:in `<class:Base>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:894:in `<module:Sinatra>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:22:in `<top (required)>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/main.rb:1:in `require'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/main.rb:1:in `<top (required)>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra.rb:1:in `require'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra.rb:1:in `<top (required)>'
from /Users/user/Desktop/repos/palindrome_app/app.rb:1:in `require'
from /Users/user/Desktop/repos/palindrome_app/app.rb:1:in `<top (required)>'
from /Users/user/Desktop/repos/palindrome_app/test/test_helper.rb:3:in `require_relative'
from /Users/user/Desktop/repos/palindrome_app/test/test_helper.rb:3:in `<top (required)>'
from /Users/user/Desktop/repos/palindrome_app/test/site_pages_test.rb:1:in `require_relative'
from /Users/user/Desktop/repos/palindrome_app/test/site_pages_test.rb:1:in `<top (required)>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_test_loader.rb:17:in `require'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_test_loader.rb:17:in `block in <main>'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_test_loader.rb:5:in `select'
from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_test_loader.rb:5:in `<main>'
rake aborted!
Command failed with status (1)
/Users/user/.rbenv/versions/3.0.0/bin/bundle:23:in `load'
/Users/user/.rbenv/versions/3.0.0/bin/bundle:23:in `<main>'
Tasks: TOP => test
(See full trace by running task with --trace)
tl;dr:将 sinatra
升级到版本 2.1.0
。(或者,将 ruby 降级到 v2.7
。)
您是运行宁旧gem版本(特别是sinatra v2.0.3
),最新 版本 ruby (v3.0.0
)。这样做可能会 运行 遇到各种兼容性问题,因为您可能会丢失来自这些库的关键 ruby 3.0 兼容性更新。
sinatra
变更日志中有 various mentions 个 ruby 2.7+ 关键字弃用修复。
具体来说,这个错误:
gems/3.0.0/gems/sinatra-2.0.3/lib/sinatra/base.rb:1629:in `compile!'
已由 this change in this PR, which shipped as part of sinatra v2.0.8
. Also, additional fixes 修复,已作为 v2.1.0
版本的一部分添加。