Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid byte sequence when running on CI #12

Open
olliebennett opened this issue Jan 9, 2018 · 1 comment
Open

Invalid byte sequence when running on CI #12

olliebennett opened this issue Jan 9, 2018 · 1 comment
Assignees

Comments

@olliebennett
Copy link

When running Ruumba on our CI (continuous integration) system, it's failing with the backtrace below (triggered on this line).

Any idea what I can do to fix this? It doesn't appear specifically related to this gem, but I've tried workarounds mentioned elsewhere (setting LC_ALL and LANG env vars).

We experienced similar problems (again, on CI only) with Brakeman - presidentbeef/brakeman#102. In that case, setting LC_ALL as suggested fixed the problem. No luck with Ruumba.

Is it possible that this gem could rescue the exception, and identify any incorrectly formatted/encoded files in some way, rather than crashing?

bash: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)
/pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:58:in `gsub': invalid byte sequence in US-ASCII (ArgumentError)
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:58:in `parse_file'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:37:in `extract'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:105:in `block (2 levels) in copy_erb_files'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:104:in `open'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:104:in `block in copy_erb_files'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:100:in `each'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:100:in `copy_erb_files'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:29:in `run'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/bin/ruumba:70:in `<top (required)>'
	from /pipeline/cache/bundle-install/ruby/2.4.0/bin/ruumba:25:in `load'
	from /pipeline/cache/bundle-install/ruby/2.4.0/bin/ruumba:25:in `<main>'

The script used to execute ruumba (bin/ruumba) is:

#!/usr/bin/env bash

bundle exec ruumba -D -e app/views -c .ruumba.yml

Running bin/ruumba on my local system runs smoothly (reporting "no offenses detected").

@olliebennett
Copy link
Author

Solved!

I set the following environment variables:

ENV Key Value
LANG C
LANGUAGE C.UTF-8
LC_ALL C.UTF-8

I suppose the CI machine didn't have the requested locales available; in a previous step, the following error was shown.

/bin/bash: line 64: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8): No such file or directory

As suspected, not to do with this gem specifically, although it triggered it for whatever reason and it's possible a code change could make it more flexible in some way.

Please close if not relevant!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants