nio4r 终止,显示不支持的后端 (ArgumentError) 与 Puma

huangapple go评论72阅读模式
英文:

nio4r terminates with unsupported backend (ArgumentError) with Puma

问题

我使用了 bundle update 来更新我的 Gemfile 中的开发支持和测试 Gems,因为所有生产环境的 Gems 都被锁定在特定版本上。更新后,nio4r 仍然保持在2.5.2版本,因为它被锁定了。然而,在更新后,nio4r 出现了以下错误消息:nio4r-2.5.2/lib/nio/selector.rb:17:in 'initialize': 不支持的后端: (ArgumentError)

堆栈跟踪如下:
(请注意,这是升级 Ruby 和 Rails 的努力,从正确进行测试和重构基础部分开始。)

Puma starting in single mode...
* Puma version: 6.3.0 (ruby 2.7.2-p137) ("Mugi No Toki Itaru")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 11436
* Listening on http://[::1]:3001
* Listening on http://127.0.0.1:3001
Exiting
Traceback (most recent call last):
        20: from bin/rails:4:in `<main>'
        19: from bin/rails:4:in `require'
        18: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands.rb:18:in `<top (required)>'
        17: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/command.rb:46:in `invoke'
        16: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/command/base.rb:69:in `perform'
        15: from ruby/2.7.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        14: from ruby/2.7.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        13: from ruby/2.7.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        12: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands/server/server_command.rb:142:in `perform'
        11: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands/server/server_command.rb:142:in `tap'
        10: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands/server/server_command.rb:147:in `block in perform'
         9: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands/server/server_command.rb:53:in `start'
         8: from ruby/2.7.0/gems/rack-2.2.7/lib/rack/server.rb:327:in `start'
         7: from ruby/2.7.0/gems/puma-6.3.0/lib/rack/handler/puma.rb:76:in `run'
         6: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/launcher.rb:194:in `run'
         5: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/single.rb:53:in `run'
         4: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/server.rb:248:in `run'
         3: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/server.rb:248:in `new'
         2: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/reactor.rb:28:in `initialize'
         1: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/reactor.rb:28:in `new'
ruby/2.7.0/gems/nio4r-2.5.2/lib/nio/selector.rb:17:in `initialize': 不支持的后端:  (ArgumentError)
英文:

I used bundle update to update my gemfile's development support and test gems, as all the production gems are version locked. After the update, nio4r remained at 2.5.2 as it had been locked. However, after the update, nio4r failed with message: nio4r-2.5.2/lib/nio/selector.rb:17:in &#39;initialize&#39;: unsupported backend: (ArgumentError)

The stack trace is as follows:
(Note, this is an effort to upgrade Ruby and Rails, starting by getting testing right & refactoring base.)

Puma starting in single mode...
* Puma version: 6.3.0 (ruby 2.7.2-p137) (&quot;Mugi No Toki Itaru&quot;)
*  Min threads: 5
*  Max threads: 5
*  Environment: development
*          PID: 11436
* Listening on http://[::1]:3001
* Listening on http://127.0.0.1:3001
Exiting
Traceback (most recent call last):
        20: from bin/rails:4:in `&lt;main&gt;&#39;
        19: from bin/rails:4:in `require&#39;
        18: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands.rb:18:in `&lt;top (required)&gt;&#39;
        17: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/command.rb:46:in `invoke&#39;
        16: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/command/base.rb:69:in `perform&#39;
        15: from ruby/2.7.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch&#39;
        14: from ruby/2.7.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command&#39;
        13: from ruby/2.7.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run&#39;
        12: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands/server/server_command.rb:142:in `perform&#39;
        11: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands/server/server_command.rb:142:in `tap&#39;
        10: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands/server/server_command.rb:147:in `block in perform&#39;
         9: from ruby/2.7.0/gems/railties-5.2.5/lib/rails/commands/server/server_command.rb:53:in `start&#39;
         8: from ruby/2.7.0/gems/rack-2.2.7/lib/rack/server.rb:327:in `start&#39;
         7: from ruby/2.7.0/gems/puma-6.3.0/lib/rack/handler/puma.rb:76:in `run&#39;
         6: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/launcher.rb:194:in `run&#39;
         5: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/single.rb:53:in `run&#39;
         4: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/server.rb:248:in `run&#39;
         3: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/server.rb:248:in `new&#39;
         2: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/reactor.rb:28:in `initialize&#39;
         1: from ruby/2.7.0/gems/puma-6.3.0/lib/puma/reactor.rb:28:in `new&#39;
ruby/2.7.0/gems/nio4r-2.5.2/lib/nio/selector.rb:17:in `initialize&#39;: unsupported backend:  (ArgumentError)

答案1

得分: 1

经过对堆栈跟踪的分析,我发现 Puma::Server.run 方法没有启动 :ruby 反应器。在研究 Puma 时,我发现它只与版本 '〜> 6' 兼容。它已经从 6.0.0 升级到了 6.3.0。在查看变更日志时,我发现在 Puma 变更历史 中,引入了 #2522 的重大变更。

这个问题是在 5.2.0 中出现的,但影响在从 6.0.0 到 6.3.0 的过渡中显现出来。

解决方法是升级 nio4r 到版本 '〜> 2'。我升级到了 2.5.9,一切都正常了。

注意:上面提到的变更 #2522 涉及到 NIL:Selector 源代码。该源代码显示,后端从早期的 [:ruby] 扩展到了在失败的语句 17 中选择的 [:ruby, nil]。实际上,被选择的值就是 nil。

英文:

Working through the stack trace, I found that the Puma::Server.run method was not starting the :ruby reactor. Researching Puma, I found it version locked only to '~> 6'. It had been upgraded from 6.0.0 to 6.3.0. Reviewing the change log, I found that in Puma Change History, the breaking change was #2522.
>That occurred in 5.2.0, however the impact showed in the transition from 6.0.0 to 6.3.0.

Resolution is to upgrade nio4r using '~> 2'. Mine went to 2.5.9 and all was well.

Note: Change #2522, noted above, referred to NIL:Selector source code. That source code shows that the backends were expanded from the earlier [:ruby] to [:ruby, nil] in failing statement 17. Nil was, in fact, the value that was being chosen.

huangapple
  • 本文由 发表于 2023年6月25日 21:38:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76550682.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定