报错核心代码如下:
点击查看代码
gem install jekyll
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby22/lib/ruby/gems/2.2.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
C:/Ruby22/bin/ruby.exe -r ./siteconf20180227-30372-ssgv65.rb extconf.rb
creating Makefile
current directory: C:/Ruby22/lib/ruby/gems/2.2.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR=" clean
current directory: C:/Ruby22/lib/ruby/gems/2.2.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR="
generating ruby_http_parser-i386-mingw32.def
compiling ruby_http_parser.c
In file included from c:/Ruby22/include/ruby-2.2.0/ruby.h:33:0,
from ruby_http_parser.c:1:
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:111:14: error: size of array 'ruby_check_sizeof_voidp' is negative
In file included from c:/Ruby22/include/ruby-2.2.0/ruby.h:33:0,
from ruby_http_parser.c:1:
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h: In function 'rb_obj_freeze_inline':
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1156:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1157:2: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1158:6: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1158:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h: In function 'rb_data_object_get':
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1192:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h: In function 'rb_obj_written':
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1271:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1271:34: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h: In function 'rb_num2char_inline':
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1344:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1344:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1344:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1344:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1344:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1344:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1345:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1345:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1345:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h: In function 'rb_class_of':
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1670:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h: In function 'rb_type':
c:/Ruby22/include/ruby-2.2.0/ruby/ruby.h:1687:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ruby_http_parser.c: In function 'on_message_begin':
ruby_http_parser.c:108:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby_http_parser.c: In function 'on_header_value':
ruby_http_parser.c:146:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby_http_parser.c: In function 'on_headers_complete':
ruby_http_parser.c:192:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby_http_parser.c: In function 'on_body':
ruby_http_parser.c:213:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby_http_parser.c: In function 'on_message_complete':
ruby_http_parser.c:232:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby_http_parser.c: In function 'Parser_execute':
ruby_http_parser.c:314:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ruby_http_parser.c:314:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ruby_http_parser.c:314:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ruby_http_parser.c:314:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby_http_parser.c:315:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ruby_http_parser.c:315:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ruby_http_parser.c:315:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ruby_http_parser.c:320:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby_http_parser.c:330:7: warning: unknown conversion type character 'z' in format [-Wformat]
ruby_http_parser.c:330:7: warning: unknown conversion type character 'z' in format [-Wformat]
ruby_http_parser.c:330:7: warning: too many arguments for format [-Wformat-extra-args]
ruby_http_parser.c: In function 'Parser_set_header_value_type':
ruby_http_parser.c:451:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
make: *** [ruby_http_parser.o] Error 1
make failed, exit code 2
Gem files will remain installed in C:/Ruby22/lib/ruby/gems/2.2.0/gems/http_parser.rb-0.6.0 for inspection.
Results logged to C:/Ruby22/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/http_parser.rb-0.6.0/gem_make.out
问题溯源:
经反复测试,报错原因为Ruby的安装目录存在中文
解决方案:
卸载Ruby,重新安装Ruby-devkit,并确保安装路径不含空格。注意:Jekll官网安装说明中指明,Ruby须安装带开发包的版本(Ruby-devkit)。
附加:
安装jekyll之前
- 除了确保Ruby安装路径不含空格外,在Ruby安装流程结束之际,安装程序中会有一个安装复选框(默认已勾选),点击“完成”后,会跳出安装额外窗口,输入3,回车即可。
- 安装好MinGW,且确保其已配置好环境变量。