我不知道如何解决这个问题,无法在网上找到信息来帮助,但我发现这是与nio4r宝石有关,但没有太多其他的。请帮助,让我知道我能做什么,任何更多的信息。我用的是fedora, linux.
[ben@localhost-live hello_app]$ rails s
=> Booting Puma
=> Rails 7.0.4.3 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.6.5 (ruby 3.2.1-p31) ("Birdie's Version")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 33779
* Listening on http://127.0.0.1:3000
* Listening on http://[::1]:3000
Exiting
<internal:/usr/local/rvm/rubies/ruby-3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require': /usr/local/rvm/gems/ruby-3.2.1/gems/nio4r-2.5.9/lib/nio4r_ext.so: invalid ELF header - /usr/local/rvm/gems/ruby-3.2.1/gems/nio4r-2.5.9/lib/nio4r_ext.so (LoadError)
from <internal:/usr/local/rvm/rubies/ruby-3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /usr/local/rvm/gems/ruby-3.2.1/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /usr/local/rvm/gems/ruby-3.2.1/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
from /usr/local/rvm/gems/ruby-3.2.1/gems/nio4r-2.5.9/lib/nio.rb:42:in `<main>'
from <internal:/usr/local/rvm/rubies/ruby-3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from <internal:/usr/local/rvm/rubies/ruby-3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /usr/local/rvm/gems/ruby-3.2.1/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /usr/local/rvm/gems/ruby-3.2.1/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
from /usr/local/rvm/gems/ruby-3.2.1/gems/puma-5.6.5/lib/puma/reactor.rb:24:in `initialize'
from /usr/local/rvm/gems/ruby-3.2.1/gems/puma-5.6.5/lib/puma/server.rb:244:in `new'
from /usr/local/rvm/gems/ruby-3.2.1/gems/puma-5.6.5/lib/puma/server.rb:244:in `run'
from /usr/local/rvm/gems/ruby-3.2.1/gems/puma-5.6.5/lib/puma/single.rb:53:in `run'
from /usr/local/rvm/gems/ruby-3.2.1/gems/puma-5.6.5/lib/puma/launcher.rb:193:in `run'
from /usr/local/rvm/gems/ruby-3.2.1/gems/puma-5.6.5/lib/rack/handler/puma.rb:72:in `run'
from /usr/local/rvm/gems/ruby-3.2.1/gems/rack-2.2.6.4/lib/rack/server.rb:327:in `start'
from /usr/local/rvm/gems/ruby-3.2.1/gems/railties-7.0.4.3/lib/rails/commands/server/server_command.rb:38:in `start'
from /usr/local/rvm/gems/ruby-3.2.1/gems/railties-7.0.4.3/lib/rails/commands/server/server_command.rb:143:in `block in perform'
from <internal:kernel>:90:in `tap'
from /usr/local/rvm/gems/ruby-3.2.1/gems/railties-7.0.4.3/lib/rails/commands/server/server_command.rb:134:in `perform'
from /usr/local/rvm/gems/ruby-3.2.1/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /usr/local/rvm/gems/ruby-3.2.1/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/local/rvm/gems/ruby-3.2.1/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /usr/local/rvm/gems/ruby-3.2.1/gems/railties-7.0.4.3/lib/rails/command/base.rb:87:in `perform'
from /usr/local/rvm/gems/ruby-3.2.1/gems/railties-7.0.4.3/lib/rails/command.rb:48:in `invoke'
from /usr/local/rvm/gems/ruby-3.2.1/gems/railties-7.0.4.3/lib/rails/commands.rb:18:in `<main>'
from <internal:/usr/local/rvm/rubies/ruby-3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from <internal:/usr/local/rvm/rubies/ruby-3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /usr/local/rvm/gems/ruby-3.2.1/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from bin/rails:4:in `<main>'
[ben@localhost-live hello_app]$
当本机扩展编译不正确时,就会出现这个问题。您需要重新编译nio4r gem的本地扩展。这个问题有很多很多可能的原因:
- 您通过传入无效参数来编译扩展(例如,告诉它为错误的体系结构编译)
- 您在另一个操作系统上编译扩展,然后手动将它们移动到此系统
- 您在过去编译了扩展,然后进行了主要的系统升级或操作系统更改,然后尝试继续使用以前编译的扩展
还有其他可能的原因,但最直接的解决方案是重新编译扩展:
bundle pristine nio4r
如果您仍然有这个问题,那么请确保您的打包器平台是ruby
而只有ruby
:
bundle config force_ruby_platform true
这将有以下效果:
忽略当前机器的平台,只安装
ruby
平台宝石。因此,带有本地扩展的gem将从源代码编译。
然后重试bundle pristine nio4r
强制重新编译。