gpt4 book ai didi

ruby-on-rails - 尝试通过 ubuntu WSL 终端在 rails 上安装 ruby​​ 时出现多个错误

转载 作者:行者123 更新时间:2023-12-04 10:42:24 24 4
gpt4 key购买 nike

我目前正在通过 windows 子系统为 linux 使用全新安装的 ubuntu 18.04.2 LTS。我安装了 ruby​​ 使用

sudo apt-get install ruby2.5-dev

我正在尝试使用以下方法安装 rails
gem install rails -v 5.2.3

这给了我一个 Gem::FilePermissionError 错误,可以通过使用 sudo 修复,但多个在线消息来源说不要使用 sudo 来安装 gems,尽管它们似乎都在使用 MacOS。

当我忽略它们并尝试使用 sudo 安装时,我得到了这个:
    Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.5.0/gems/nokogiri-1.10.7/ext/nokogiri
/usr/bin/ruby2.5 -r ./siteconf20200123-2772-1f46u2w.rb extconf.rb
checking if the C compiler accepts ... *** 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)2.5
--help
--clean
/usr/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
from /usr/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
from /usr/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /usr/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:416:in `<main>'

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

/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.7/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/nokogiri-1.10.7 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.7/gem_make.out

如果不是在 Windows 中使用的 exe 文件,我似乎无法找到安装“开发工具”的方法,我也不太确定我实际需要什么“开发工具”。

mkmf.log 是这样说的:
    "gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fdebug-prefix-map=/build/ruby2.5-B0MvC_/ruby2.5-2.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC  conftest.c  -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby-2.5  -lpthread -lgmp -ldl -lcrypt -lm   -lc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */

我不知道这意味着什么。任何帮助,将不胜感激。

最佳答案

您缺少一个编译器,可能还缺少 WSL 设置中的许多其他基本库和工具。希望这将涵盖您需要的大部分内容:

sudo apt-get install build-essential
sudo apt-get install libxml2-dev libsqlite3-dev zlib1g-dev liblzma-dev

关于ruby-on-rails - 尝试通过 ubuntu WSL 终端在 rails 上安装 ruby​​ 时出现多个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59873006/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com