Skip to content

Instantly share code, notes, and snippets.

@tygerbytes
Last active December 29, 2016 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tygerbytes/f40735f107a28be4897e669b61a0117b to your computer and use it in GitHub Desktop.
Save tygerbytes/f40735f107a28be4897e669b61a0117b to your computer and use it in GitHub Desktop.
Ruby 2.3 on Windows: Fix "incompatible character encoding: UTF-8 and ASCII-8BIT" error
diff --git a/lib/ruby/2.3.0/resolv.rb b/lib/ruby/2.3.0/resolv.rb
index 9a981b9..c519e0e 100644
--- a/lib/ruby/2.3.0/resolv.rb
+++ b/lib/ruby/2.3.0/resolv.rb
@@ -773,7 +773,7 @@ class Resolv
service = [host, port]
id = DNS.allocate_request_id(host, port)
request = msg.encode
- request[0,2] = [id].pack('n')
+ request[0,2] = [id].pack('U')
return @senders[[service, id]] =
Sender.new(request, data, sock, host, port)
end
@tygerbytes
Copy link
Author

After installing Ruby 2.3 on windows, gem install bundle fails with the following error:

ERROR: While executing gem ... <Encoding::CompatibilityError>
  incompatible character encodings: UTF-8 and ASCII-8BIT

Edit resolv.rb as shown in the gist and make the change on line 776. Then try running gem install bundle again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment