【问题标题】:Could not find json-1.8.1 in any of the sources在任何来源中都找不到 json-1.8.1
【发布时间】:2016-06-30 10:11:16
【问题描述】:

我正在使用 react-rails 做一个项目,但是当我运行时

bundle install

我明白了

Could not find json-1.8.1 in any of the sources

具体来说,这是整个错误

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/montana/.rvm/gems/ruby-2.3.0/gems/json-1.8.1/ext/json/ext/generator
/Users/montana/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160629-5602-i1di2t.rb extconf.rb
creating Makefile

current directory: /Users/montana/.rvm/gems/ruby-2.3.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Users/montana/.rvm/gems/ruby-2.3.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:47: error: too few arguments provided to function-like macro invocation
    VALUE result = rb_str_new(FBUFFER_PAIR(fb));
                                              ^
/Users/montana/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/intern.h:797:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) __extension__ (    \
        ^
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:11: warning: incompatible pointer to integer conversion initializing 'VALUE' (aka 'unsigned long') with an expression of type 'VALUE (const char *, long)' (aka 'unsigned long (const char *, long)') [-Wint-conversion]
    VALUE result = rb_str_new(FBUFFER_PAIR(fb));
          ^        ~~~~~~~~~~
1 warning and 1 error generated.
make: *** [generator.o] Error 1

stackoverflow 上有很多关于这个的帖子,并且尝试了大多数“解决方案”,但似乎没有一个对我有用,我也跑了

gem list | grep json

它说我有 json gem via

 json (1.8.3)
 multi_json (1.10.1)

我试图停止 spring,更新 gems 和 bundler。我也跑过

rbenv rehash

无济于事,仍然出现此错误,非常感谢任何输入。

【问题讨论】:

  • 清除 Gemfile.lock 并再次运行 bundle install 会发生什么?
  • 感谢 oreoluwa 的回复,它给了我完全相同的错误。为了确认我确实有 json,我还运行了 'json -- version'

标签: ruby-on-rails ruby react-rails


【解决方案1】:

我上次在Ubuntu 上遇到了问题,我尝试安装这个library 并且效果很好。

sudo apt-get install libgmp3-dev

您可以参考文档:Failed to build gem json native extension

【讨论】:

    【解决方案2】:

    您可能希望降低 ruby​​ 版本或提高 json 版本。见:https://github.com/flori/json/issues/229

    快速浏览了 json 1.8.1 gemspec 并没有提到截至今天的 ruby​​ 2.3.0 支持。

    【讨论】:

    • 我使用 json 1.8.1 和 ruby​​ 2.3.1,直到现在都没有问题。
    • 非常感谢 gemspec,我最终运行 'rvm install ruby​​-2.1.1' 然后运行 ​​'rvm use ruby​​-2.1.1' 就像一个魅力。
    猜你喜欢
    • 2014-06-05
    • 2018-01-31
    • 1970-01-01
    • 1970-01-01
    • 2012-03-12
    • 2013-12-25
    • 2017-07-18
    • 2012-07-22
    • 2011-11-28
    相关资源
    最近更新 更多