gem install jekyll失败

时间:2018-12-21 23:38:47

标签: ruby rubygems

我正在通过gem安装Jekyll。按照此说明https://learn.cloudcannon.com/jekyll/install-jekyll-on-windows/安装Ruby并在cmd中键入“ gem install jekyll”后,出现以下错误:

C:\Windows\system32>gem install jekyll
Traceback (most recent call last):
    15: from <internal:gem_prelude>:2:in `<internal:gem_prelude>'
    14: from <internal:gem_prelude>:2:in `require'
    13: from C:/tools/ruby25/lib/ruby/2.5.0/rubygems.rb:1388:in `<top (required)>'
    12: from C:/tools/ruby25/lib/ruby/2.5.0/rubygems.rb:1388:in `require'
    11: from C:/tools/ruby25/lib/ruby/2.5.0/rubygems/defaults/operating_system.rb:3:in `<top (required)>'
    10: from C:/tools/ruby25/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/singleton.rb:27:in `enable_dll_search_paths'
     9: from C:/tools/ruby25/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/msys2_installation.rb:96:in `enable_dll_search_paths'
     8: from C:/tools/ruby25/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/msys2_installation.rb:86:in `mingw_bin_path'
     7: from C:/tools/ruby25/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/msys2_installation.rb:73:in `msys_path'
     6: from C:/tools/ruby25/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/msys2_installation.rb:48:in `iterate_msys_paths'
     5: from C:/tools/ruby25/lib/ruby/2.5.0/win32/registry.rb:542:in `open'
     4: from C:/tools/ruby25/lib/ruby/2.5.0/win32/registry.rb:435:in `open'
     3: from C:/tools/ruby25/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/msys2_installation.rb:49:in `block in iterate_msys_paths'
     2: from C:/tools/ruby25/lib/ruby/2.5.0/win32/registry.rb:611:in `each_key'
     1: from C:/tools/ruby25/lib/ruby/2.5.0/win32/registry.rb:910:in `export_string'
C:/tools/ruby25/lib/ruby/2.5.0/win32/registry.rb:910:in `encode': U+7F51 to IBM437 in conversion from UTF-16LE to UTF-8 to IBM437 (Encoding::UndefinedConversionError)

我遵循的步骤如下:

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

choco install ruby -y

gem install jekyll

1 个答案:

答案 0 :(得分:0)

在文本编辑器中打开文件C:/tools/ruby25/lib/ruby/2.5.0/win32/registry.rb。找到以LOCALE = Encoding开头的行。将此行从原来的位置更改为LOCALE = Encoding::UTF_8,保存文件,然后重试gem install jekyll操作。

这里已经存在与question和Ruby跟踪器上的some bugs相似的东西,但它们并不容易发现。

如果该解决方案不起作用,请尝试在chcp 1256窗口中运行命令chcp 1252cmd.exe。这将更改使用中的代码页,也可能解决此问题。