当我尝试构建
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 │
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────
我正在使用基于 Ubuntu 22.04 LTS 的 Linux Mint 21.1 Vera(最新的 LTS 版本)和内核 5.15.0-56-generic,并安装了以下软件包:
gcc make ubuntu-dev-tools ruby ruby-dev ruby-colorize
据我所知应该足以构建
colorls
。但看起来我仍然缺少一些东西而且我无法弄清楚,什么。有什么想法吗?
你缺少build-essential。您可以在什么是 build-essential Ubuntu?
阅读更多内容安装它:
sudo apt-get install build-essential
与您的问题无关,请勿使用
sudo gem install ...
除非运行gem install ...
失败并出现错误告诉您它must与sudo
一起运行。