簡體   English   中英

安裝 json Ruby gem 時出錯

[英]Error installing json Ruby gem

我正在運行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並且它特別想要那個版本。

還有其他想法嗎?

問題是由於您不在正確的目錄中而出現的。 請先轉到您的 rails 目錄文件夾,然后像這樣運行此命令:

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

然后它的工作正常。

這似乎是 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 作品。

查找和更新拉入 JSON gem 的 gem 應該可以工作。 但是,對我有用的另一件事是更新正在安裝的 JSON 版本。

bundle update json

這是有效的,因為它將 JSON 更新到與較新的 Ruby 兼容的 1.8.6 版。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM