无法加载EventMachine C扩展;使用纯红宝石反应堆

col*_*lin 1 ruby bundle ruby-on-rails ruby-on-rails-3

我遇到了麻烦,在Rails项目中?redmine2.3),rails版本是3.2

开始项目

bundle exec thin start -p 8080 -e production -s 5 -d
Run Code Online (Sandbox Code Playgroud)

错误信息

(eval):9: warning: already initialized constant Bundler::Dsl::RAILS_VERSION_IS_3
(eval):9: warning: previous definition of RAILS_VERSION_IS_3 was here
(eval):9: warning: already initialized constant Bundler::Dsl::RAILS_VERSION_IS_3
(eval):9: warning: previous definition of RAILS_VERSION_IS_3 was here
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
/var/wtn/vendor/cache/ruby/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:8:in `require': libruby.so.2.0: cannot open shared object file: No such file or directory - /var/wtn/vendor/cache/ruby/2.0.0/gems/eventmachine-1.0.3/lib/rubyeventmachine.so (LoadError)
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:8:in `<top (required)>'
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/thin-1.6.2/lib/thin.rb:7:in `require'
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/thin-1.6.2/lib/thin.rb:7:in `<top (required)>'
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/thin-1.6.2/bin/thin:5:in `require'
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/thin-1.6.2/bin/thin:5:in `<top (required)>'
    from /var/wtn/vendor/cache/ruby/2.0.0/bin/thin:23:in `load'
    from /var/wtn/vendor/cache/ruby/2.0.0/bin/thin:23:in `<main>'
Run Code Online (Sandbox Code Playgroud)

运行时发生相同的错误 rails -v

rails -v
(eval):9: warning: already initialized constant Bundler::Dsl::RAILS_VERSION_IS_3
(eval):9: warning: previous definition of RAILS_VERSION_IS_3 was here
Run Code Online (Sandbox Code Playgroud)

bundle exec .....在项目中运行会产生相同的错误

问题解决了,请看我在三楼的评论,有答案

Jer*_*yal 19

对于 Windows 10 上的 Ruby 2.4 和 eventmachine 1.2.6。

您必须先卸载eventmachine,然后使用平台 ruby​​ 再次安装它:

gem uninstall eventmachine  (select all versions if prompted)

gem install eventmachine --platform ruby
Run Code Online (Sandbox Code Playgroud)


Sim*_*ast 13

我在 Windows 10 上尝试使用 Jekyll 的 LiveReload 功能时遇到此错误消息。这里的其他答案并没有完全解决问题,或者有下次bundle install运行时再次出现问题的风险。

我的解决方案(取自本网站)是:

  1. 运行此控制台命令

    gem uninstall eventmachine 
    
    Run Code Online (Sandbox Code Playgroud)

    并选择eventmachine-1.2.7-x64-mingw32从您的系统中卸载gems。

  2. Gemfile在您的项目目录中编辑并在其中添加以下行:

    gem 'eventmachine', '1.2.7', git: 'https://github.com/eventmachine/eventmachine.git', tag: 'v1.2.7'
    
    Run Code Online (Sandbox Code Playgroud)
  3. bundle install
    
    Run Code Online (Sandbox Code Playgroud)
  4. 使用命令清理你的 jekyll 构建和缓存

    bundle exec jekyll clean
    
    Run Code Online (Sandbox Code Playgroud)

您现在可以使用该--livereload参数而不会出现任何问题,即使您bundle install将来执行也是如此。

  • 谢谢,我在 Windows 10 上尝试使用 Jekyll 的 LiveReload 功能时也遇到了此错误消息,它也适用于我。 (2认同)

Emj*_*jey 7

如果您使用的是Windows

  1. 转到此文件夹 C:\Ruby24-x64\lib\ruby\gems\2.4.0\gems\eventmachine-1.2.5-x64-mingw32\lib

  2. 打开此文件eventmachine.rb

  3. 将其写require 'em/pure_ruby'在文件的第一行代码中

这将使其没有问题。

  • 它给了我以下错误 - `The ``SortedSet`` 类已从 ``set`` 库中提取。您必须使用 ``sorted_set`` gem 或其他替代品。(运行时错误)`。在我的机器上,您指定的文件的路径是 - `C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\eventmachine-1.2.7-x64-mingw32\lib` (3认同)

Pra*_*thy 6

此处的相关错误消息如下:

Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
Run Code Online (Sandbox Code Playgroud)

尝试重新安装eventmachinegem:

gem uninstall eventmachine
bundle install
Run Code Online (Sandbox Code Playgroud)

请参阅创建数据库时的 Rails/Ruby 错误:无法加载 EventMachine C 扩展Rails - 无法运行应用程序:无法加载 EventMachine C 扩展;有关如何处理此问题的更多建议。