Gem::Ext::BuildError: 错误: 无法构建 gem 本机扩展。在 CenOS 6.5 上

问题描述 投票:0回答:5

安装Redmine。 我试过了,

bundle install --without development test postgresql sqlite

,但是错误。

Gem::Ext::BuildError: 错误: 无法构建 gem 本机扩展。

current directory:
/usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
/usr/local/bin/ruby -r ./siteconf20161228-21055-1dxe9y9.rb extconf.rb
creating Makefile

current directory:
/usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean

current directory:
/usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
generator.c: In function ‘generate_json’:
generator.c:861: error: ‘rb_cFixnum’ undeclared (first use in this
function)
generator.c:861: error: (Each undeclared identifier is reported only
once
generator.c:861: error: for each function it appears in.)
generator.c:863: error: ‘rb_cBignum’ undeclared (first use in this
function)
At top level:
cc1: warning: unrecognized command line option "-Wno-self-assign"
cc1: warning: unrecognized command line option
"-Wno-constant-logical-operand"
cc1: warning: unrecognized command line option
"-Wno-parentheses-equality"
cc1: warning: unrecognized command line option
"-Wno-tautological-compare"
make: *** [generator.o] error 1

make failed, exit code 2

Gem files will remain installed in
/usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.3 for inspection.
Results logged to
/usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/json-1.8.3/gem_make.out

An error occurred while installing json (1.8.3), and Bundler
cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before
bundling.

所以,我尝试了

gem install json -v '1.8.3
,但无法解决。

您介意读一下这个问题吗?

ruby-on-rails json ruby redmine gem-bundler
5个回答
4
投票

Ruby 2.4 非常新。事实上,它仅在三天前发布。

由于 Ruby 2.4 中有一些重要的内部更改,因此很可能许多 gem(以及 Redmine 本身)尚未与该版本的 Ruby 兼容。

从您的错误消息来看,确实似乎需要调整 JSON gem 才能处理 Ruby 2.4 中有关整数的一些更改。

您现在应该使用旧版本的 Ruby,例如红宝石 2.3.3。正如您在 http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Ruby-interpreter 上看到的,Redmine 需要特定的 Ruby 版本,具体取决于 Redmine 的版本。


0
投票

我现在也有同样的问题。 要解决此问题,请使用

bundler
手动安装最新版本的
rmagick
gem install
,并使用
gem update
bundle update
更新所有其他软件包。 这解决了
json 1.8.3
ruby 2.4
的依赖问题。

但事后我遇到了更多问题。 看起来

ruby 2.4
对数字的解释做了一些改变,这意味着它不再与
rail 4.x
兼容(请参阅这篇文章)。 更新
rails
及其依赖项似乎还不可能,因为 redmine 需要
protected_attributes
,这取决于
activemodel (< 5.0, >= 4.0.1)
rails 5.x
取决于
activemodel 5.x

如果更新破坏了向后兼容性,尤其是对于编程语言而言,这总是很糟糕的:(


0
投票

错误:执行 gem 时...(Gem::FilePermissionError) 您没有 /usr/bin 目录的写入权限。


-1
投票

首次运行

gem install bundler

它安装较新的捆绑程序并解决本机扩展依赖关系

然后运行

bundle install 

它应该可以解决你的问题


-1
投票

似乎 json gem 在较新的 ruby 版本(2.4+)中存在错误,makandracards 的 answer 提出了一个简单易用的解决方案。

答案是更新 json gem 的版本来解决该错误并成功安装 gem。因此,它使用 --conservative 选项更新 json gem。

bundle update json --conservative

© www.soinside.com 2019 - 2024. All rights reserved.