You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Fedora Linux安装Ruby工具Nanoc时遇原生扩展编译错误求助

在Fedora上安装Nanoc失败的解决方法

问题描述

在全新安装的Fedora Linux系统中,已通过dnf install ruby成功安装Ruby(含rubygems),但使用gem install nanoc或sudo gem install nanoc安装Nanoc时失败,报错信息如下:

Building native extensions. This could take a while...
ERROR: Error installing nanoc:
ERROR: Failed to build gem native extension.

current directory: /home/ja/.local/share/gem/ruby/3.3.0/gems/rbtree-0.4.6

/usr/bin/ruby extconf.rb
checking for ruby/version.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include=${opt-dir}/include
--without-opt-include
--with-opt-lib=${opt-dir}/lib64
--without-opt-lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)
--enable-debug
--disable-debug
--with-ruby-dir
--without-ruby-dir
--with-ruby-include=${ruby-dir}/include
--without-ruby-include
--with-ruby-lib=${ruby-dir}/lib64
--without-ruby-lib
/usr/share/ruby/mkmf.rb:480:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

from /usr/share/ruby/mkmf.rb:606:in `block in try_compile'
from /usr/share/ruby/mkmf.rb:555:in `with_werror'
from /usr/share/ruby/mkmf.rb:606:in `try_compile'
from /usr/share/ruby/mkmf.rb:1151:in `block in have_header'
from /usr/share/ruby/mkmf.rb:983:in `block in checking_for'
from /usr/share/ruby/mkmf.rb:344:in `block (2 levels) in postpone'
from /usr/share/ruby/mkmf.rb:314:in `open'
from /usr/share/ruby/mkmf.rb:344:in `block in postpone'
from /usr/share/ruby/mkmf.rb:314:in `open'
from /usr/share/ruby/mkmf.rb:340:in `postpone'
from /usr/share/ruby/mkmf.rb:982:in `checking_for'
from /usr/share/ruby/mkmf.rb:1150:in `have_header'
from extconf.rb:8:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/home/ja/.local/share/gem/ruby/3.3.0/extensions/x86_64-linux/3.3.0/rbtree-0.4.6/mkmf.log

extconf failed, exit code 1

解决步骤

报错中明确提示**"You have to install development tools first"**,这是因为编译Ruby原生扩展需要依赖完整的开发工具链和Ruby的开发头文件,执行以下步骤即可解决:

  • 安装Fedora官方的开发工具组,包含编译所需的编译器、make等工具:

    sudo dnf groupinstall "Development Tools"
    
  • 安装Ruby开发包,提供编译原生扩展必需的头文件:

    sudo dnf install ruby-devel
    
  • 重新尝试安装Nanoc:

    gem install nanoc
    

    (如果遇到权限问题,可使用sudo gem install nanoc,但更推荐保持用户级安装,确保~/.local/share/gem/ruby/3.3.0/bin路径已添加到系统PATH环境变量中)

内容的提问来源于stack exchange,提问作者zektiv

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 04:06:21