【问题标题】:Failed to build gem native extension?构建 gem 原生扩展失败?
【发布时间】:2021-03-02 17:44:40
【问题描述】:

我最近尝试通过运行 gem install rails 通过 gem 安装 rails。但是,它总是失败并显示以下错误消息。

Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    current directory: D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3/ext/websocket-driver
D:/Program\ Files/Ruby30-x64/bin/ruby.exe -I D:/Program\ Files/Ruby30-x64/lib/ruby/3.0.0 -r ./siteconf20210303-3696-skc9xl.rb extconf.rb
creating Makefile

current directory: D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3/ext/websocket-driver
make "DESTDIR=" clean
Makefile:269: *** multiple target patterns.  Stop.

current directory: D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3/ext/websocket-driver
make "DESTDIR="
Makefile:269: *** multiple target patterns.  Stop.

make failed, exit code 2

Gem files will remain installed in D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3 for inspection.
Results logged to D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/websocket-driver-0.7.3/gem_make.out

有谁知道这里实际发生了什么?我会很感激任何答案。谢谢

【问题讨论】:

    标签: ruby-on-rails ruby rubygems


    【解决方案1】:

    通常,编译 gem 扩展时出现的“多目标模式”错误是由安装 Ruby 或 gem 的目录名称中的空格引起的。

    尤其是在 Windows 上,您应该将 Ruby 安装到不包含空格的目录,而不是当前位置 D:/Program Files/Ruby30-x64。为了解决这个问题,我建议卸载 Ruby 并重新安装到更合适的位置。

    【讨论】:

    • 谢谢,会试试的
    • 我尝试将我的 Ruby 移动到另一个没有空格的目录并更改了环境变量。现在,它工作顺利。非常感谢。
    猜你喜欢
    • 2012-03-22
    • 1970-01-01
    • 1970-01-01
    • 2020-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多