Forum: Ruby Incompatible Encoding Error in Ruby 2.3.3

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
308a6d714ef3fcedd76b315a90dcedd8?d=identicon&s=25 Sai kiran Nemali (nkiran)
on 2017-03-22 11:33
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.
4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (shevegen)
on 2017-03-22 18:46
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
(http://i.loveruby.net/en/projects/setup/) 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.
308a6d714ef3fcedd76b315a90dcedd8?d=identicon&s=25 Sai kiran Nemali (nkiran)
on 2017-03-23 07:18
Hi Robert Heiler,

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:
     - https://rubygems.org/
  - 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.
This topic is locked and can not be replied to.