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

时间:2014-08-14 00:22:23

标签: ruby-on-rails ruby json windows

问题第1部分

最初是尝试使用

创建我的第一个应用程序
C:\>rails new first_app

我得到以下内容......

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

[...不得不在这里删除一些,但我附上完整的]

  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:

[...不得不在这里删除一些,但我附上完整的]

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和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

问题第2部分

跑完......

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

..正确安装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

1 个答案:

答案 0 :(得分:0)

首先,有很多警告,但真正的罪魁祸首是标有'错误'的警告:

error: size of array 'ruby_check_sizeof_voidp' is negative

Google搜索此错误可获得此StackOverflow问题:Why does installing Ruby on Rails generate error "size of array 'ruby_check_sizeof_voidp' is negative"?

我认为答案非常有用:

  

当您安装了错误版本的DevKit时会发生这种情况   为您的Ruby版本

建议值得尝试:

  

要解决此问题,请重新安装Ruby并安装正确的DevKit   对于您的Ruby版本,如标题为“哪个   开发工具包?“在http://rubyinstaller.org/downloads