ruby 构建颜色时缺少开发工具

gv8xihay  于 2023-04-29  发布在  Ruby
关注(0)|答案(1)|浏览(103)

当我尝试构建colorls时,它失败了,并抱怨缺少开发工具。我已经安装了所有需要的软件包-至少我知道所有需要的。我不知道缺少哪些开发工具以及需要安装哪些软件包。

❯ sudo gem install colorls
Building native extensions. This could take a while...
ERROR:  Error installing colorls:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/3.0.0/gems/clocale-0.0.4/ext/clocale
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230421-86160-l0scrv.rb extconf.rb
checking for locale.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
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/$(RUBY_BASE_NAME)3.0
    --with-locale-dir
    --without-locale-dir
    --with-locale-include
    --without-locale-include=${locale-dir}/include
    --with-locale-lib
    --without-locale-lib=${locale-dir}/lib
/usr/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/lib/ruby/3.0.0/mkmf.rb:613:in `try_cpp'
    from /usr/lib/ruby/3.0.0/mkmf.rb:1124:in `block in have_header'
    from /usr/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
    from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
    from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
    from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
    from /usr/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
    from /usr/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
    from /usr/lib/ruby/3.0.0/mkmf.rb:1123:in `have_header'
    from extconf.rb:9:in `<main>'

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

  /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/clocale-0.0.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/3.0.0/gems/clocale-0.0.4 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/clocale-0.0.4/gem_make.out

好吧,它会抱怨缺少库或头文件。如建议,我检查日志文件:

❯ bat /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/clocale-0.0.4/mkmf.log
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/clocale-0.0.4/mkmf.log
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ "x86_64-linux-gnu-gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-3.0.0 -I/usr/include/ruby-3.0.0/ruby/bac
       │ kward -I/usr/include/ruby-3.0.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -ffile-prefix-map=/build/ruby3.0-p
       │ 8XSIY/ruby3.0-3.0.2=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c  -L. -L/usr/li
       │ b/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -rdynamic -Wl,
       │ -export-dynamic     -lruby-3.0  -lm   -lc"
   2   │ collect2: error: ld returned 1 exit status
   3   │ checked program was:
   4   │ /* begin */
   5   │ 1: #include "ruby.h"
   6   │ 2: 
   7   │ 3: int main(int argc, char **argv)
   8   │ 4: {
   9   │ 5:   return !!argv[argc];
  10   │ 6: }
  11   │ /* end */
  12   │ 
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────

我用的是Linux Mint 21。1基于Ubuntu 22的Vera(最新LTS版本)。04 LTS with kernel 5.15.0-56-generic并安装了以下软件包:gcc make ubuntu-dev-tools ruby ruby-dev ruby-colorize
据我所知,这应该足以构建colorls。但看起来我还是漏掉了什么我不知道是什么。有什么想法吗

col17t5w

col17t5w1#

您缺少build-essential。阅读更多What is build-essential Ubuntu?
安装它与:

sudo apt-get install build-essential

与您的问题无关,不要使用sudo gem install ...,除非运行gem install ...失败并出现错误,告诉您它 * 必须 * 使用sudo运行。

相关问题