【问题标题】:An error occurred while installing json (1.8.1) and Bundler cannot continue安装 json (1.8.1) 时出错,Bundler 无法继续
【发布时间】:2020-10-13 06:51:29
【问题描述】:

当我尝试运行 bundle install 时,出现以下错误:

Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.9
Installing json 1.8.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/geethu/.rvm/gems/ruby-2.3.1/gems/json-1.8.1/ext/json/ext/generator/home/geethu/.rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20201013-6347-q8bzg1.rb extconf.rb

创建 Makefile 当前目录:/home/geethu/.rvm/gems/ruby-2.3.1/gems/json-1.8.1/ext/json/ext/generator 使“DESTDIR=”干净 当前目录:/home/geethu/.rvm/gems/ruby-2.3.1/gems/json-1.8.1/ext/json/ext/generator 制作“DESTDIR=” 编译生成器.c

../fbuffer/fbuffer.h: In function ‘fbuffer_to_s’:

../fbuffer/fbuffer.h:175:47: 错误:宏“rb_str_new”需要 2 个参数,但只给出 1 个 VALUE 结果 = rb_str_new(FBUFFER_PAIR(fb));

../fbuffer/fbuffer.h:175:20: warning: initialization makes integer from pointer without a cast [-Wint-conversion]

VALUE 结果 = rb_str_new(FBUFFER_PAIR(fb));

Makefile:238: recipe for target 'generator.o' failed

make: *** [generator.o] 错误 1

make failed, exit code 2
Gem files will remain installed in /home/geethu/.rvm/gems/ruby-2.3.1/gems/json-1.8.1 for inspection.

结果记录到 /home/geethu/.rvm/gems/ruby-2.3.1/extensions/x86_64-linux/2.3.0/json-1.8.1/gem_make.out

Using minitest 5.3.4
Using thread_safe 0.3.4
Using builder 3.2.2
Using erubis 2.7.0
Using rack 1.5.2
Using mime-types 1.25.1
Using polyglot 0.3.5
Using arel 5.0.1.20140414130214
Using bcrypt 3.1.7
Using coderay 1.1.0
Using debug_inspector 0.0.2
Using bundler 1.12.5
Using callsite 0.0.11
Using cancan 1.6.10
Using coffee-script-source 1.7.0
Using execjs 2.1.0
Using thor 0.19.1
Using currencies 0.4.2
Using database_cleaner 1.3.0
Using orm_adapter 0.5.0
Using diff-lcs 1.2.5
Using tilt 1.4.1
Using hike 1.2.3
Using multi_json 1.10.1
Using method_source 0.8.2
Using subexec 0.2.3
Using mini_portile 0.6.0
Using mousetrap-rails 1.4.6
Using nested_form 0.3.2
Using pg 0.17.1
Using slop 3.5.0
Using rolify 3.4.0
Using rspec-core 2.14.8
Using rspec-mocks 2.14.6
Using rubyzip 1.1.3
Using sass 3.2.19
Using workflow 1.1.0
An error occurred while installing json (1.8.1), and Bundler cannot continue.

在捆绑之前确保gem install json -v '1.8.1' 成功。

【问题讨论】:

  • 运行gem install json -v '1.8.1'会得到什么?
  • 错误:安装 json 时出错:错误:无法构建 gem 原生扩展。
  • gem 列表显示:json (1.8.6, 1.8.3, 1.8.2)
  • 你能编辑你的问题并发布整个日志输出吗?很难理解为什么它只在第一行就失败了。另外你在什么操作系统上?什么版本的 ruby​​ 和 bundler?
  • 操作系统:Ubuntu 16.04,ruby:ruby 2.3.1p112(2016-04-26 修订版 54768)[x86_64-linux],捆绑器:捆绑器版本 1.12.5

标签: ruby-on-rails json bundler


【解决方案1】:

尝试更新您的Gemfile 以使用json@1.8.2 而不是1.8.1 - 根据this thread Ruby 2.2.x 与json 1.8.1 不兼容。

1.8.2 应该在功能上相似,并且不会影响您的任何其他依赖项。

您也可以运行 bundle update json 让 bundler 尝试为您修复它 - 但这可能会使您的版本比 1.8.2 更新得多,我不确定。

尝试几件事并恢复您的更改并没有什么坏处。

【讨论】:

  • 将其版本更改为 1.8.2 适合我,Ruby 2.3.8 和 Rails 3.2.11
猜你喜欢
  • 2017-04-08
  • 2018-09-08
  • 1970-01-01
  • 1970-01-01
  • 2023-03-06
  • 2016-03-14
  • 2022-01-20
  • 2017-02-09
  • 2020-01-16
相关资源
最近更新 更多