How to fix a Ruby script that fails with an encoding error: "\ xD8" in US-ASCII?

When starting a project, I get the following error:

cucumber --format junit --guess --out ./ 

This is mistake:

 Checkout:workspace / /var/lib/hudson/jobs/PersOC-CucumberTests/workspace - hudson.remoting.LocalChannel@3b815cce Using strategy: Default Last Built Revision: Revision 3dc11ccba9c86308b422d6261ecde95d0a4ae999 (origin/master) Checkout:workspace / /var/lib/hudson/jobs/CucumberTests/workspace - hudson.remoting.LocalChannel@3b815cce Fetching changes from the remote Git repository Fetching upstream changes from /srv/git/cucumber.git Commencing build of Revision 14627f9a6682b82a9b4d64172278a646da358c24 (origin/master) Checking out Revision 14627f9a6682b82a9b4d64172278a646da358c24 (origin/master) [workspace] $ /bin/sh -xe /tmp/hudson6604637626131848657.sh + cucumber --format junit --guess --out ./ /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.5/lib/json/common.rb:155:in `encode': "\xD8" on US-ASCII (Encoding::InvalidByteSequenceError) from /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.5/lib/json/common.rb:155:in `initialize' from /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.5/lib/json/common.rb:155:in `new' from /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.5/lib/json/common.rb:155:in `parse' from /usr/lib64/ruby/gems/1.9.1/gems/gherkin-2.11.2/lib/gherkin/i18n.rb:14:in `<class:I18n>' from /usr/lib64/ruby/gems/1.9.1/gems/gherkin-2.11.2/lib/gherkin/i18n.rb:6:in `<module:Gherkin>' from /usr/lib64/ruby/gems/1.9.1/gems/gherkin-2.11.2/lib/gherkin/i18n.rb:5:in `<top (required)>' from /usr/lib64/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require' [DEBUG] Skipping watched dependency update for build: CucumberTests #168 due to result: FAILURE Finished: FAILURE 

Each individual file in this project is marked:

 #!/bin/env ruby # encoding: utf-8 # -*- coding: utf-8 -*- 

What can i try?

+4
source share
2 answers

There are problems with LC encodings of the medium.

Linux

 export LANG=en_US.UTF-8 

OS X (pre Mnt. Lion)

 export LC_CTYPE=en_US.UTF-8 

OS X (Mnt. Lion and later)

 export LC_ALL=en_US.UTF-8 
+2
source

The problem can also be fixed in the Ruby it-self code by adding the following code:

 Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 
+1
source

Source: https://habr.com/ru/post/1434663/


All Articles