1. 程式人生 > 其它 >Windows環境安裝jekll報錯

Windows環境安裝jekll報錯

報錯核心程式碼如下:

點選檢視程式碼
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,且確保其已配置好環境變數。