gpt4 book ai didi

ruby-on-rails - "Error installing rails"因为 "extconf.rb failed"在 Ubuntu 18.04

转载 作者:行者123 更新时间:2023-12-03 19:31:10 25 4
gpt4 key购买 nike

我无法安装 Rails。

背景:我的(全新)系统 = Ubuntu 18.04、Ruby 2.6.0、最新的 rvm 和 bundler 已安装和更新。安装 Ruby 后我做的第一件事就是做 sudo apt install ruby-railtiessudo apt install rails ...我不知道为什么我没有使用 gem install .在那之后,我再也没有成功执行过rails new但我曾经部分执行过它,但它失败了,那是我开始进入兔子洞的时候。

当我输入 rails -v我明白了:

Traceback (most recent call last):
4: from /home/globewalldesk/.rvm/gems/ruby-2.6.0/bin/ruby_executable_hooks:24:in `<main>'
3: from /home/globewalldesk/.rvm/gems/ruby-2.6.0/bin/ruby_executable_hooks:24:in `eval'
2: from /home/globewalldesk/.rvm/gems/ruby-2.6.0/bin/rails:23:in `<main>'
1: from /usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:482:in `block in replace_bin_path'
/usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:462:in `block in replace_bin_path': can't find executable rails for gem railties. railties is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)

当我尝试执行 gem install rails 时,我明白了:
Successfully installed concurrent-ruby-1.1.4

HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.

Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.

For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0

Successfully installed i18n-1.5.2
Successfully installed thread_safe-0.3.6
Successfully installed tzinfo-1.2.5
Successfully installed activesupport-5.2.2
Successfully installed rack-2.0.6
Successfully installed rack-test-1.1.0
Successfully installed mini_portile2-2.4.0
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.

current directory: /home/globewalldesk/.rvm/gems/ruby-2.6.0/gems/nokogiri-1.10.1/ext/nokogiri
/usr/share/rvm/rubies/ruby-2.6.0/bin/ruby -I /usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0 -r ./siteconf20190116-22693-tbjpnz.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
*** 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/share/rvm/rubies/ruby-2.6.0/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
/usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem': mini_portile2 is not part of the bundle. Add it to your Gemfile. (Gem::LoadError)
from extconf.rb:469:in `<main>'

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

/home/globewalldesk/.rvm/gems/ruby-2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/globewalldesk/.rvm/gems/ruby-2.6.0/gems/nokogiri-1.10.1 for inspection.
Results logged to /home/globewalldesk/.rvm/gems/ruby-2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.1/gem_make.out

我浏览了 installation instructions以及这里和其他地方的许多类似问题,并尝试了很多东西,但似乎没有任何效果。

我在尝试时收到类似的错误消息 gem install nokogiri .

帮助!

更新:这是 mkmf.log 文件:
"gcc -o conftest -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/x86_64-linux -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/ruby/backward -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0 -I.    -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wrestrict -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable  -fPIC  conftest.c  -L. -L/usr/share/rvm/rubies/ruby-2.6.0/lib -Wl,-rpath,/usr/share/rvm/rubies/ruby-2.6.0/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic     -Wl,-rpath,/usr/share/rvm/rubies/ruby-2.6.0/lib -L/usr/share/rvm/rubies/ruby-2.6.0/lib -lruby  -lm   -lc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */

"gcc -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/x86_64-linux -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/ruby/backward -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0 -I. -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wrestrict -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */

更新 2:根据 Javier 的建议,我查看了安装 Nokogiri 的文档并找到了命令 gem install nokogiri -- --use-system-libraries ,这奏效了。然后我对 rails 和 railties 做了同样的事情。

现在,当我尝试运行 rails new 时收到不同的错误消息:
Traceback (most recent call last):
2: from /home/globewalldesk/.rvm/gems/ruby-2.6.0/bin/rails:23:in `<main>'
1: from /usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:482:in `block in replace_bin_path'
/usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:462:in `block in replace_bin_path': can't find executable rails for gem railties. railties is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
O

更新 3:

我接受了哈维尔的回答。我一直在使用全新安装(尝试),所以如果我完全重新开始并不重要。我不知道是什么最终搞砸了我的系统(也许是因为我没有先删除 rvm 行就从另一个系统复制了一个旧的 .bashrc 文件?),但是完全卸载了所有 Ruby、Rails、其他 gems 和 rvm,然后重新安装应该解决问题。

更新最后一个:

完全卸载 Ruby、Rails,尤其是 RVM 花了很多时间。我没有意识到 Bash 配置文件脚本有多重要,或者需要彻底删除有关 RVM 的行,或者 RVM 设置的某些环境变量的状态有多重要。我认为我在安装 Rails 时遇到问题的主要原因仅仅是因为我从旧的 bash 配置文件中复制了 RVM 设置。我应该删除它们。

现在一切都按预期工作。

最佳答案

这是安装 nokogiri 的文档 https://nokogiri.org/tutorials/installing_nokogiri.html , rvm 有一个注释:

Note for RVM users: you may require libgmp, consider running sudo apt-get install libgmp-dev.



使用 rvm 删除 ruby​​ https://rvm.io/rubies/removing
rvm remove 2.6.0

安装

ruby
rvm install 2.6.0

rails
gem install rails

对于现有项目
bundle install

关于ruby-on-rails - "Error installing rails"因为 "extconf.rb failed"在 Ubuntu 18.04,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54225803/

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