0

I am installing Jekyll via gem. After I install the Ruby following this instruction https://learn.cloudcannon.com/jekyll/install-jekyll-on-windows/ and type the "gem install jekyll" in cmd, I get the error below:

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)

The steps I followed are below:

@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
anothermh
  • 9,815
  • 3
  • 33
  • 52
Gen
  • 441
  • 4
  • 11
  • I have edited your post for you to convert the output to a code block. I recommend that you read [https://stackoverflow.com/help/formatting](https://stackoverflow.com/help/formatting) for future posts or updates, because properly formatting your examples are a crucial part of getting a response on stackoverflow. – anothermh Dec 22 '18 at 01:04
  • Thank you anothermh! It's my second time to post my question and I appreciate your link for formatting things – Gen Dec 22 '18 at 14:53

1 Answers1

0

Open the file C:/tools/ruby25/lib/ruby/2.5.0/win32/registry.rb in a text editor. Locate the line that begins with LOCALE = Encoding. Change this line from whatever it is to LOCALE = Encoding::UTF_8, save the file, and then retry your gem install jekyll operation.

There is a substantially similar question here already and some bugs on the Ruby tracker but they are not easily discovered.

If this solution doesn't work then try running the command chcp 1256 or chcp 1252 in your cmd.exe window. This will change the code page in use and may also resolve this issue.

anothermh
  • 9,815
  • 3
  • 33
  • 52