简体   繁体   English

如何为Windows上的Ruby on Rails安装json gem?

[英]How do i install json gem for Ruby on Rails for Windows?

PROBLEM PART 1 问题第1部分

Initially was trying to create my first application using 最初是尝试使用创建我的第一个应用程序

C:\>rails new first_app

and i get the following... 我得到以下...

C:\rails_projects>rails new first_app
DL is deprecated, please use Fiddle
      exist
  identical  README.rdoc
  identical  Rakefile
  identical  config.ru
  identical  .gitignore
  identical  Gemfile
      exist  app

[... had to remove some here but i attached complete] [...不得不在这里删除一些,但我附上了完整的]

  identical  vendor/assets/stylesheets/.keep
        run  bundle install
DL is deprecated, please use Fiddle
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11

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

    C:/Ruby200/bin/ruby.exe -r ./siteconf20140813-12680-m0uhap.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
generating generator-i386-mingw32.def
compiling generator.c
In file included from c:/Ruby200/include/ruby-2.0.0/ruby.h:33:0,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:125:14: error: size of array 'ruby_check_sizeof_voidp' is negative
In file included from c:/Ruby200/include/ruby-2.0.0/ruby.h:33:0,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:

[... had to remove some here but i attached complete] [...不得不在这里删除一些,但我附上了完整的]

generator.c: In function 'cState_buffer_initial_length_set':
generator.c:1317:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/extensions/x86-mingw32/2.0.0/json-1.8.1/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.1'` succeeds before bundling.

VERSIONS and PATH 版本和路径

C:\>rails -v && ruby -v && git --version
DL is deprecated, please use Fiddle
Rails 4.1.4
ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
git version 1.9.4.msysgit.0

C:\>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Prog
ram Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86
)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Java\jdk8\bin;C:\Program Files (x86)\Git\cmd;C:\Ruby200\bin

PROBLEM PART 2 问题第二部分

After running.. 运行后..

C:\>gem install json --platform=ruby

..to install json correctly, I get the following response in my console... ..要正确安装json,我会在控制台中收到以下响应...

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing json:
        ERROR: Failed to build gem native extension.

C:/Ruby200/bin/ruby.exe -r ./siteconf20140813-6704-mznpfx.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
generating generator-i386-mingw32.def
compiling generator.c
In file included from c:/Ruby200/include/ruby-2.0.0/ruby.h:33:0,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:125:14: error: size of array 'ruby_check_sizeof_voidp' is negative
In file included from c:/Ruby200/include/ruby-2.0.0/ruby.h:33:0,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_float_value':
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:826:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_num2char_inline':
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:1214:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:1214:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:1214:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:1215:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:1215:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:1215:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_class_of':
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:1515:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_type':
c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:1532:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
In file included from generator.c:1:0:
../fbuffer/fbuffer.h: In function 'fbuffer_append_str':
../fbuffer/fbuffer.h:118:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
../fbuffer/fbuffer.h:118:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
../fbuffer/fbuffer.h:118:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'convert_UTF8_to_JSON_ASCII':
generator.c:129:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:129:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:129:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:130:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:130:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:130:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'convert_UTF8_to_JSON':
generator.c:227:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:227:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:227:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:228:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:228:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:228:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'mHash_to_json':
generator.c:330:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'mArray_to_json':
generator.c:342:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'mFixnum_to_json':
generator.c:352:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'mBignum_to_json':
generator.c:362:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'mFloat_to_json':
generator.c:372:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'mString_to_json':
generator.c:394:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'mTrueClass_to_json':
generator.c:449:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'mFalseClass_to_json':
generator.c:459:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'mNilClass_to_json':
generator.c:469:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_configure':
generator.c:524:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:532:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:532:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:532:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:533:34: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:533:34: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:533:34: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:540:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:540:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:540:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:541:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:541:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:541:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:548:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:548:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:548:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:549:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:549:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:549:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:556:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:556:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:556:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:557:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:557:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:557:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:564:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:564:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:564:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:565:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:565:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:565:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'set_state_ivars':
generator.c:613:21: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:613:21: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:613:21: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:615:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:615:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:615:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_to_h':
generator.c:630:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'generate_json_object':
generator.c:700:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:700:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:700:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'generate_json_array':
generator.c:746:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:746:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:746:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_prepare_buffer':
generator.c:860:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_partial_generate':
generator.c:890:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'isArrayOrObject':
generator.c:902:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:902:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:902:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:903:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:903:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:903:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_generate':
generator.c:920:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_initialize':
generator.c:950:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_init_copy':
generator.c:968:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:969:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_indent':
generator.c:1012:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_indent_set':
generator.c:1024:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1026:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1026:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1026:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1035:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1035:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1035:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_space':
generator.c:1049:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_space_set':
generator.c:1062:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1064:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1064:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1064:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1073:31: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1073:31: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1073:31: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_space_before':
generator.c:1086:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_space_before_set':
generator.c:1098:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1100:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1100:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1100:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1109:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1109:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1109:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_object_nl':
generator.c:1123:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_object_nl_set':
generator.c:1136:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1138:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1138:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1138:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1146:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1146:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1146:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_array_nl':
generator.c:1159:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_array_nl_set':
generator.c:1171:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1173:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1173:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1173:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1181:34: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1181:34: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c:1181:34: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_check_circular_p':
generator.c:1196:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_max_nesting':
generator.c:1208:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_max_nesting_set':
generator.c:1220:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_allow_nan_p':
generator.c:1233:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_ascii_only_p':
generator.c:1245:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_quirks_mode_p':
generator.c:1256:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_quirks_mode_set':
generator.c:1267:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_depth':
generator.c:1279:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_depth_set':
generator.c:1291:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_buffer_initial_length':
generator.c:1304:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
generator.c: In function 'cState_buffer_initial_length_set':
generator.c:1317:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
make: *** [generator.o] Error 1

make failed, exit code 2

First, there are a lot of warnings, but the real culprit is the one marked by 'error' : 首先,有很多警告,但真正的罪魁祸首是“错误”标记的警告:

error: size of array 'ruby_check_sizeof_voidp' is negative

Googling for this error gets us this StackOverflow question : Why does installing Ruby on Rails generate error "size of array 'ruby_check_sizeof_voidp' is negative"? 谷歌搜索此错误使我们得到这个StackOverflow问题: 为什么安装Ruby on Rails会产生错误“数组'ruby_check_sizeof_voidp'的大小为负数”?

I think the answer there is really helpful : 我认为那里的答案确实有帮助:

This happens when you have installed the wrong version of the DevKit for your version of Ruby 当您为Ruby版本安装了错误版本的DevKit时,就会发生这种情况

And the suggestion worth to try : 值得尝试的建议:

To correct the problem, reinstall Ruby and install the correct DevKit for your version of Ruby, as indicated in the section titled "Which Development Kit?" 要解决此问题,请重新安装Ruby并为您的Ruby版本安装正确的DevKit,如标题为“哪个开发工具包?”的部分所述。 at http://rubyinstaller.org/downloads http://rubyinstaller.org/downloads

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM