簡體   English   中英

如何為Windows上的Ruby on Rails安裝json gem?

[英]How do i install json gem for Ruby on Rails for 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.

版本和路徑

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

問題第二部分

運行后..

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

首先,有很多警告,但真正的罪魁禍首是“錯誤”標記的警告:

error: size of array 'ruby_check_sizeof_voidp' is negative

谷歌搜索此錯誤使我們得到這個StackOverflow問題: 為什么安裝Ruby on Rails會產生錯誤“數組'ruby_check_sizeof_voidp'的大小為負數”?

我認為那里的答案確實有幫助:

當您為Ruby版本安裝了錯誤版本的DevKit時,就會發生這種情況

值得嘗試的建議:

要解決此問題,請重新安裝Ruby並為您的Ruby版本安裝正確的DevKit,如標題為“哪個開發工具包?”的部分所述。 http://rubyinstaller.org/downloads

暫無
暫無

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

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