如何修复失败的编码错误的Ruby脚本:“\xD8”在US-ASCII? [英] How to fix Ruby script which fails with encoding error: "\xD8" on US-ASCII?

查看:283
本文介绍了如何修复失败的编码错误的Ruby脚本:“\xD8”在US-ASCII?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行项目时出现以下错误:

I get the following error when running a project with:

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

这是错误:

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

此项目中的每个文件都标有:

Every single file in this project is marked with:

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

我可以尝试什么?

推荐答案

您的环境LC编码有问题。

There are issues with your environments LC encodings.

export LANG=en_US.UTF-8



OS X(pre Mnt。 Lion)



OS X (pre Mnt. Lion)

export LC_CTYPE=en_US.UTF-8



OS X(Mnt。Lion及更高版本)



OS X (Mnt. Lion and later)

export LC_ALL=en_US.UTF-8

这篇关于如何修复失败的编码错误的Ruby脚本:“\xD8”在US-ASCII?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆