Ruby 捆绑安装错误';安装json(1.7.3)和#x27;

Ruby 捆绑安装错误';安装json(1.7.3)和#x27;,ruby,json,installation,bundle,osx-elcapitan,Ruby,Json,Installation,Bundle,Osx Elcapitan,我是初学者,当我尝试安装Bundle时,我不知道如何修复我的错误。我正在学习Schneems课程(目前正在做routes\u controller\u练习) 这是我的错误: 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 cr

我是初学者,当我尝试安装Bundle时,我不知道如何修复我的错误。我正在学习Schneems课程(目前正在做routes\u controller\u练习)

这是我的错误:

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:

现在进行此练习:


更新: 所以我做了:

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.
安装带有本机扩展的eventmachine 0.12.10
Gem::Ext::BuildError:错误:无法生成Gem本机扩展。
/Users/admin/.rbenv/versions/2.2.3/bin/ruby-r./siteconf20151101-99125-1vfqvuu.rbextconf.rb
正在检查ruby.h、rubysig.h中的rb_陷阱_立即数。。。不
正在检查rb\u线程\u阻塞\u区域()。。。不
正在检查sys/inotify.h中的inotify_init()。。。不
正在检查sys/syscall.h中的\uu NR\u inotify\u init。。。不
正在检查sys/uio.h中的writev()。。。对
正在检查rb\u线程\u检查\u整数()。。。对
正在检查rb_time_new()。。。对
正在检查sys/event.h。。。对
正在检查sys/queue.h。。。对
创建Makefile
使“DESTDIR=”干净
使“DESTDIR=”
编译binder.cpp
在binder.cpp:20中包含的文件中:
./project.h:103:10:致命错误:“未找到openssl/ssl.h”文件
#包括
^
生成1个错误。
make:**[binder.o]错误1
make失败,退出代码2
Gem文件仍将安装在/Users/admin/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/eventmachine-0.12.10中,以供检查。
结果记录到/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
安装eventmachine(0.12.10)时出错,捆绑程序无法继续。
在绑定之前,请确保'gem install eventmachine-v'0.12.10'成功。
ip-10-0-66-6:routes\u controller\u exercise Admin$gem安装事件机-v“0.12.10”
构建本机扩展。这可能需要一段时间。。。
错误:安装eventmachine时出错:
错误:无法生成gem本机扩展。

解决方案 好的,我已经卸载了rails,并在斯坦福网站上重新安装了它

现在一切都很好!我不知道问题出在哪里,但现在我安装的Bundle没有问题。

在您添加的文件中

gem'json','1.7.3'

此后,

捆绑安装


问题的一部分是由于
rb\u str\u new
中的更改

这是他们GitHub页面上的一个相关问题:

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


如果您正在使用bundler,您应该转到您的
Gemfile
并使用
gem'json','>=1.8.3'

将json版本更改为1.8.3或更高版本,因为版本1.7.3已经是bundler根据错误消息尝试安装的版本。使用
gem install json-v'1.7.3'
可能会为您提供额外的信息来解决问题,或者允许您添加额外的选项,如
--使用opt dir=[dir]
bundle config
),谢谢您的回答!但我不知道如何编辑我的文件。我只需要在编辑器中打开gem文件并添加:gem'json','>=1.8.3'并保存它?然后我在终端上运行bundle安装?在我的项目目录中,我有Gemfile和Gemfile.lock。在Gemfile中,我没有看到json,但在Gemfile.lock(**json(1.7.3)**)中看到了json。我是Ruby新手,所以我为一些非常基本的问题道歉。我刚刚补充了我的情况。我想我要哭了,我太糊涂了。@imagirl92只是把它添加到你的GEM文件中,正如你解释的那样,听起来是对的。如果您使用自制软件安装openssl(
brew install openssl
),您只需执行
bundle config build.eventmachine--cppflags=-I$(brew--prefix openssl)就可以了/包括
,然后再次进行
捆绑安装
。如果
捆绑更新json
不起作用,并且如果您不依赖未在
Gemfile
中指定的任何特定版本的gem,则可以删除
Gemfile。锁定
并再次运行
捆绑安装
。然后bundler将搜索与
Gemfile
中定义的版本匹配的所有gem的最佳可用版本。我认为它在@aross!非常感谢。为了确保这一点,我在最后有这样一条消息(我的Ruby版本:Ruby 2.2.3p173):
rdoc的安装后消息:根据您的Ruby版本,您可能需要安装Ruby rdoc/ri数据:=1.9.2:无需执行任何操作!耶