Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber fails with json Encoding::InvalidByteSequenceError

I'm using rvm 1.15.6 and ruby-1.9.3-p194.

I've created a new Rails application with the following gems:

source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'sqlite3'
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem "rspec-rails", ">= 2.10.1", :group => [:development, :test]
gem "factory_girl_rails", ">= 3.3.0", :group => [:development, :test]
gem "cucumber-rails", ">= 1.3.0", :group => :test, :require => false
gem "capybara", ">= 1.1.2", :group => :test
gem "database_cleaner", ">= 0.7.2", :group => :test

When I run:

bundle exec cucumber

I get an error:

json-1.7.5/lib/json/common.rb:155:in `encode': "\xD8" on US-ASCII (Encoding::InvalidByteSequenceError)

Here's the full trace:

/Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/json-1.7.5/lib/json/common.rb:155:in `encode': "\xD8" on US-ASCII (Encoding::InvalidByteSequenceError)
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/json-1.7.5/lib/json/common.rb:155:in `initialize'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/json-1.7.5/lib/json/common.rb:155:in `new'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/json-1.7.5/lib/json/common.rb:155:in `parse'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/i18n.rb:14:in `<class:I18n>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/i18n.rb:6:in `<module:Gherkin>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/i18n.rb:5:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/lexer/i18n_lexer.rb:1:in `require'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/lexer/i18n_lexer.rb:1:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin.rb:1:in `require'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin.rb:1:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:2:in `require'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:2:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/cucumber-1.2.1/bin/cucumber:11:in `require'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/cucumber-1.2.1/bin/cucumber:11:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/bin/cucumber:19:in `load'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/bin/cucumber:19:in `<main>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/bin/ruby_noexec_wrapper:14:in `<main>'

I'm mystified. Any solution or suggestions for troubleshooting?

EDIT: This is without creating any Cucumber feature files. I get the same thing if I create feature files.

like image 628
Daniel Kehoe Avatar asked Aug 26 '12 12:08

Daniel Kehoe


1 Answers

I've had the same issue, it looks it is because your shell's encoding

Take a look at this page https://github.com/cucumber/gherkin

Linux

export LANG=en_US.UTF-8

OS X

export LC_CTYPE=en_US.UTF-8
like image 58
Ramzi Avatar answered Oct 02 '22 08:10

Ramzi