Incompatible Encoding Error in Ruby 2.3.3

Hi,can anyone help me on this.

When installing any gem ,error the below error is encountered.

ERROR: While executing gem … (Encoding::CompatibilityError)
incompatible character encodings: UTF-8 and ASCII-8BIT

The error is observed only when Ruby 2.3.3 is installed and the issue is
observed only on few PC’s.

PC Configuration:
Windows 7 Professional Service Pack 1

Thanks,
Sai Kiran.

Quite an annoying error.

What Encoding do you use?

You can find out via irb for example.

Start it, then:

“abc”.encoding.to_s

For me it is “ISO-8859-1”.

The error that you get is a bit unusual because ASCII-8BIT should not be
there. Does your system perhaps default to it?

If you are not using UTF-8, rubygems should default to it.

You can also try to install a gem locally, by downloading; and if it
still fails, you can try via setup.rb which still works
(setup.rb) but I would first try to find
out what is wrong with your encoding. Other ruby people on windows do
not seem to get this error as easily so perhaps something is unique to
your system.

What is the language that you use on your machine btw? I assume it may
be some non-standard, somewhat exotic language.

Hi Robert H.,

Thanks for quick response.

Ruby Version:

  C:\Users\snemala>ruby -v
  ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]

Encoding:

  C:\Users\snemala>irb
  irb(main):001:0> "abc".encoding.to_s
  => "IBM437"

Encoding of my PC is IBM437

I think,the issue(Incompatible error) is observed on when ruby tries to
go to web and download the appropriate .gem file.

I have tried to installing gems locally by placing the .gem files in
C:\Ruby193\lib\ruby\gems\1.9.1\cache
and then executing command
gem install --force --local *.gem
then gems were installed successfully.

But when i have tried to update gems using - gem update

Again the same error was encountered.

Gem Env Info:

C:\Users\snemala>gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 2.5.2
  • RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [i386-mingw32]
  • INSTALLATION DIRECTORY: C:/Ruby23/lib/ruby/gems/2.3.0
  • USER INSTALLATION DIRECTORY: C:/Users/snemala/.gem/ruby/2.3.0
  • RUBY EXECUTABLE: C:/Ruby23/bin/ruby.exe
  • EXECUTABLE DIRECTORY: C:/Ruby23/bin
  • SPEC CACHE DIRECTORY: C:/Users/snemala/.gem/specs
  • SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86-mingw32
  • GEM PATHS:
    • C:/Ruby23/lib/ruby/gems/2.3.0

    • C:/Users/snemala/.gem/ruby/2.3.0

  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:
  • SHELL PATH:
    • C:\ProgramData\Oracle\Java\javapath
    • C:\Program Files (x86)\Intel\iCLS Client\
    • C:\Program Files\Intel\iCLS Client\
    • C:\Windows\system32
    • C:\Windows
    • C:\Windows\System32\Wbem
    • C:\Windows\System32\WindowsPowerShell\v1.0\
    • C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
    • C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
    • C:\Program Files (x86)\Intel\Intel(R) Management Engine
      Components\DAL
    • C:\Program Files (x86)\Intel\Intel(R) Management Engine
      Components\IPT
    • C:\Program Files\Microsoft SQL Server\110\Tools\Binn
    • C:\Python27
    • C:\Program Files\Collaborator Client
    • C:\Program Files\TortoiseSVN\bin
    • C:\Ruby200-x64\bin
    • C:\Program Files\MATLAB\MATLAB Runtime\v90\runtime\win64
    • C:\Ruby200\bin
    • C:\Ruby23\bin

Thanks,
Sai Kiran.