gpt4 book ai didi

ruby-on-rails - Nokogiri/Rails/zlib1g-dev 的问题

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:15:15 24 4
gpt4 key购买 nike

我的 Ubuntu 机器上安装了 ruby​​ v.2.3.1p112。我最近安装了 rails (v.5.2.1),但 rails 最近遇到了一些与 gem 未安装相关的问题,特别是两个 gem 和一个程序:nokogiri、sqlite3 和 zlib1g-dev。显然,如果没有这些东西,我将无法启动 Rails 服务器并开发我的应用程序,因此,如果能帮助我安装这些东西并解决问题背后的根本问题,我将不胜感激。

这是日志:

Nokogiri :

它首先说我没有权限,像这样:

foo@foo:~$ gem install nokogiri
ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /var/lib/gems/2.3.0/gems/nokogiri-1.8.5/.autotest

当我使用“sudo”时......

foo@foo:~$ sudo gem install nokogiri
[sudo] password for foo:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.5/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20181102-6590-1t6ljhe.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.3.0
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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.3
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build

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

/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.5/mkmf.log

extconf failed, exit code 1

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

zlib1g-dev 问题:

foo@foo:~$ sudo apt-get install zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
zlib1g-dev : Depends: zlib1g (= 1:1.2.8.dfsg-2ubuntu4) but 1:1.2.8.dfsg-2ubuntu4.1 is to be installed
E: Unable to correct problems, you have held broken packages.

最佳答案

mkmf.log 可能会解释为什么您不能将 nokogiri 安装为 sudo,但我会检查此文件的授权规则 /var/lib/gems/2.3.0/gems/nokogiri-1.8.5/.autotest 普通用户无法执行

您还可以查看更多信息

https://duckduckgo.com/?q=gem+Errno%3A%3AEACCES&t=canonical&ia=qa

我使用 rbenv。也许如果你使用 rbenv 你就不会尝试这个问题

我的 gems 安装在 /home/fabrizio/.rbenv 而不是 /var/lib/gems/

关于ruby-on-rails - Nokogiri/Rails/zlib1g-dev 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53123123/

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