安装json Ruby gem时出错

问题描述 投票:2回答:2

我正在运行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并且它特别需要该版本。

还有其他想法吗?

ruby-on-rails json ruby rubygems
2个回答
0
投票

这似乎是json 1.8.1 gem的常见问题。如果您明确声明它,可以使用不同版本的json,但在某些情况下,json 1.8.1是级联依赖项。例如,你可能会看到类似的东西

In Gemfile:
  rails was resolved to 4.1.5, which depends on
    actionmailer was resolved to 4.1.5, which depends on
      actionpack was resolved to 4.1.5, which depends on
        actionview was resolved to 4.1.5, which depends on
          activesupport was resolved to 4.1.5, which depends on
            json

在这种情况下,您只需将顶级gem(在本例中为rails)更改为其他版本。 4.2.6工程。


0
投票

由于您不在正确的目录中,因此会出现此问题。请先转到rails目录文件夹然后像这样运行此命令:

rails@rails:~/rails_project/btc$ gem install json -v '1.8.1'

然后它的工作正常。

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