ruby Gem::Ext::BuildError:错误:无法生成gem本机扩展,在CenOS 6.5

rxztt3cl  于 12个月前  发布在  Ruby
关注(0)|答案(4)|浏览(112)

安装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,但我不能解决它。
你能看看这道题吗?

fslejnso

fslejnso1#

Ruby 2.4是一个新的版本。事实上,它在三天前才被释放。
由于Ruby 2.4中有几个重要的内部更改,因此很可能许多gem(以及Redmine本身)尚未与此版本的Ruby兼容。
从您的错误消息来看,确实需要调整JSON gem以处理Ruby 2.4中有关整数的一些更改。
你现在应该使用一个旧版本的Ruby,例如。Ruby 2.3.3.正如您在http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Ruby-interpreter上看到的,Redmine需要特定的Ruby版本,具体取决于Redmine的版本。

bmvo0sr5

bmvo0sr52#

我现在也有同样的问题。要解决此问题,请使用gem install手动安装最新版本的bundlerrmagick,并使用gem updatebundle update更新所有其他软件包。这解决了json 1.8.3ruby 2.4的依赖性问题。
但我在后面遇到了更多的问题。它看起来像ruby 2.4在数字的解释上做了一些改变,这意味着它不再与rail 4.x兼容(see this post)。更新rails及其依赖似乎是不可能的,因为redmine需要protected_attributes,它依赖于activemodel (< 5.0, >= 4.0.1)rails 5.x依赖于activemodel 5.x
如果一个更新破坏了向后兼容性,特别是对于编程语言,这总是不好的:(

bweufnob

bweufnob3#

首次运行

gem install bundler

它安装了较新的插件并解决了本机扩展依赖性
然后运行

bundle install

应该能解决你的问题

zaq34kh6

zaq34kh64#

json gem似乎在较新的ruby版本(2.4+)中有一个bug,makandracards的answer提出了一个简单易行的解决方案。
答案是更新json gem的版本以解决bug并成功安装gem。因此,它使用--conservative选项更新json gem。
bundle update json --conservative

相关问题