ruby-on-rails - 安装 json Ruby gem 时出错

标签 ruby-on-rails json ruby rubygems

我正在运行 gem install json -v '1.8.1' 但是我收到这个错误..

gem install json -v '1.8.1'
Building native extensions.  This could take a while...
ERROR:  Error installing json:
    ERROR: Failed to build gem native extension.

    current directory: /Users/johnwilliamson/.rvm/gems/ruby-2.4.1/gems/json-1.8.1/ext/json/ext/generator
/Users/johnwilliamson/.rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20170412-72871-wada1h.rb extconf.rb
creating Makefile

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

current directory: /Users/johnwilliamson/.rvm/gems/ruby-2.4.1/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/johnwilliamson/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0/ruby/intern.h:795:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) RB_GNUC_EXTENSION_BLOCK(   \
        ^
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));
          ^        ~~~~~~~~~~
generator.c:840:25: error: use of undeclared identifier 'rb_cFixnum'
    } else if (klass == rb_cFixnum) {
                        ^
generator.c:842:25: error: use of undeclared identifier 'rb_cBignum'
    } else if (klass == rb_cBignum) {
                        ^
1 warning and 3 errors generated.
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/johnwilliamson/.rvm/gems/ruby-2.4.1/gems/json-1.8.1 for inspection.
Results logged to /Users/johnwilliamson/.rvm/gems/ruby-2.4.1/extensions/x86_64-darwin-16/2.4.0/json-1.8.1/gem_make.out

当我只运行 gem install json 时,它安装得很好,让我超越了版本 2,但是我正在尝试安装这个 https://github.com/peatio/peatio它特别想要那个版本。

还有其他想法吗?

最佳答案

查找并更新拉入 JSON gem 的 gem 应该可以工作。但是,对我有用的另一件事是更新正在安装的 JSON 版本。

bundle update json

之所以可行,是因为它将 JSON 更新为与更新的 Rubies 兼容的版本 1.8.6。

关于ruby-on-rails - 安装 json Ruby gem 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43359331/

相关文章:

ruby-on-rails - 未定义的局部变量或方法 `current_user'

json - 如何将所有解码数据写入一个 JSON 文件?

ruby-on-rails - 如果参数为大写,如何在 Rails 路由中进行 301 重定向?

ruby-on-rails - 忘记密码时设计路由错误

php - 在 laravel 护照客户端应用程序中使用访问 token 获取用户数据

javascript - 设置 xAxis 最小值和最大值时,Highstock 数据不显示

ruby-on-rails - 查找日期范围内的记录

ruby-on-rails - 除了在 Rails Controller 中使用局部变量之外,还有更好的替代方法吗?

ruby - Gem 服务器已启动但在前端不可见

sql - 通过 OR 或 AND (Arel, Rails3) 连接(粘合)where 条件