ruby - bundle 安装错误 'error occurred while installing json (1.7.3)'

标签 ruby json installation bundle osx-elcapitan

我是初学者,在尝试安装 Bundle 时无法理解如何修复错误。我正在学习 Schneems 类(class)(目前正在做 routes_controller_exercise)。

这是我的错误:

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

/Users/admin/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20151101-96612-c518oi.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
./../fbuffer/fbuffer.h:158:47: error: too few arguments provided to function-like macro invocation
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
                                          ^
/Users/admin/.rbenv/versions/2.2.3/include/ruby-2.2.0/ruby/intern.h:793: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:158:11: warning: incompatible pointer to integer conversion initializing 'VALUE' (aka 'unsigned long') with an expression of type 'VALUE (const char *, long)' [-Wint-conversion]
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
      ^        ~~~~~~~~~~
generator.c:867:22: warning: '&&' within '||' [-Wlogical-op-parentheses]
return *p == '[' && *q == ']' || *p == '{' && *q == '}';
       ~~~~~~~~~~^~~~~~~~~~~~ ~~
generator.c:867:22: note: place parentheses around the '&&' expression to silence this warning
return *p == '[' && *q == ']' || *p == '{' && *q == '}';
                 ^
       (                     )
generator.c:867:48: warning: '&&' within '||' [-Wlogical-op-parentheses]
return *p == '[' && *q == ']' || *p == '{' && *q == '}';
                              ~~ ~~~~~~~~~~^~~~~~~~~~~~
generator.c:867:48: note: place parentheses around the '&&' expression to silence this warning
return *p == '[' && *q == ']' || *p == '{' && *q == '}';
                                           ^
                                 (                     )
3 warnings and 1 error generated.
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/admin/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/json-1.7.3 for inspection.
Results logged to /Users/admin/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/json-1.7.3/gem_make.out
An error occurred while installing json (1.7.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.3'` succeeds before bundling.

我不知道该怎么办。我是初学者所以...请对我好一点!我一直在网上尝试很多解决方案,但到目前为止没有任何效果!我使用的是 El Capitan 10.11.1。

我已经使用此链接设置了 Ruby:http://guides.railsgirls.com/install/#virtual-machine .

现在做这个练习:https://github.com/schneems/routes_controller_exercise


更新:

所以我做到了:

bundle update json 

它一直有效,直到:

Installing eventmachine 0.12.10 with native extensions

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

/Users/admin/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20151101-99125-1vfqvuu.rb extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for rb_thread_check_ints()... yes
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:103:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
     ^
1 error generated.
make: *** [binder.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/admin/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/eventmachine-0.12.10 for inspection.
Results logged to /Users/admin/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/eventmachine-0.12.10/gem_make.out
An error occurred while installing eventmachine (0.12.10), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '0.12.10'` succeeds before bundling.
ip-10-0-66-6:routes_controller_exercise Admin$ gem install eventmachine -v '0.12.10'
Building native extensions.  This could take a while...
ERROR:  Error installing eventmachine:
ERROR: Failed to build gem native extension.

解决方案

好的,我已经卸载 rails 并使用 Stanford 网站重新安装它。

现在一切正常!我不知道问题出在哪里,但现在我安装 Bundle 没有任何问题。

最佳答案

部分问题是由于 rb_str_new 中的更改所致.

这是他们 GitHub 页面上的一个相关问题:https://github.com/flori/json/issues/229

据我了解,贡献者决定不修复此问题,因为它在 json 1.8.3 中正常工作。建议您升级到该版本。 json gem 有一个非常稳定的 API,因此向后兼容性通常不是问题。

如果您正在使用 bundler ,您应该转到您的 Gemfile并使用 gem 'json', '>=1.8.3' 将 json 版本更改为 1.8.3 或更高版本.

关于ruby - bundle 安装错误 'error occurred while installing json (1.7.3)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33460321/

相关文章:

css - 在不同的浏览器中呈现 CSS 而不是单独安装每个浏览器的有用程序?

php - 使用 Codeigniter 将 JSON 数据插入 mysql

ruby - 未定义的方法错误。我该怎么办?

ruby-on-rails - 如何在 Rails 中编写和包含常规 ruby​​ 类

ruby-on-rails - 很抱歉,当用户尝试注册时,heroku 出现了问题

.net - 如何将哈希表发送到 asmx web 服务?

mysql - 如何在 MySQL 中获取一个特定 JSON 键的值

macos - 如何使用productbuild构建具有自定义背景的OS X安装程序包?

powershell - 使用 PowerShell 安装 PSCX

ruby - 将 activerecord 上的访问器方法映射到 activeresource 上的属性?