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

ArgumentError: invalid byte sequence in US-ASCII on v2.2.0 in Docker #277

Open
jamesottaway opened this issue Jun 3, 2016 · 6 comments
Open

Comments

@jamesottaway
Copy link

It looks like lib/ffaker/name_ua.rb is encoded as ASCII, not UTF-8.

❯ docker run --rm -it ruby:2.3.1 bash
root@dc8455d6bc16:/# gem install ffaker -v '2.2.0'
Fetching: ffaker-2.2.0.gem (100%)
Successfully installed ffaker-2.2.0
1 gem installed
root@dc8455d6bc16:/# irb -r ffaker
/usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/utils/module_utils.rb:15:in `split': invalid byte sequence in US-ASCII (ArgumentError)
        from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/utils/module_utils.rb:15:in `const_missing'
        from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/name_ua.rb:10:in `<module:NameUA>'
        from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/name_ua.rb:6:in `<module:FFaker>'
        from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/name_ua.rb:5:in `<top (required)>'
        from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker.rb:33:in `block in <module:FFaker>'
        from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker.rb:32:in `each'
        from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker.rb:32:in `<module:FFaker>'
        from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker.rb:1:in `<top (required)>'
        from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `require'
        from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
        from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
        from /usr/local/lib/ruby/2.3.0/irb/init.rb:281:in `block in load_modules'
        from /usr/local/lib/ruby/2.3.0/irb/init.rb:279:in `each'
        from /usr/local/lib/ruby/2.3.0/irb/init.rb:279:in `load_modules'
        from /usr/local/lib/ruby/2.3.0/irb/init.rb:21:in `setup'
        from /usr/local/lib/ruby/2.3.0/irb.rb:378:in `start'
        from /usr/local/bin/irb:11:in `<main>'
root@dc8455d6bc16:/# file /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/name_ua.rb
/usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/name_ua.rb: Ruby module source, ASCII text
@oliworx
Copy link

oliworx commented Jun 25, 2016

I get the same error on GiltLab CI:

/usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/utils/module_utils.rb:15:in `split': invalid byte sequence in US-ASCII (ArgumentError)
    from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/utils/module_utils.rb:15:in `const_missing'
    from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/name_ua.rb:10:in `<module:NameUA>'
    from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/name_ua.rb:6:in `<module:FFaker>'
    from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker/name_ua.rb:5:in `<top (required)>'
    from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker.rb:33:in `require'
    from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker.rb:33:in `block in <module:FFaker>'
    from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker.rb:32:in `each'
    from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker.rb:32:in `<module:FFaker>'
    from /usr/local/bundle/gems/ffaker-2.2.0/lib/ffaker.rb:1:in `<top (required)>'

@Kukunin
Copy link

Kukunin commented Jul 30, 2016

The same for me, rolling back to 2.1.0 resolved problem

@pawelma
Copy link
Contributor

pawelma commented Oct 13, 2016

Did you tried to use export LC_ALL=en_US.UTF-8 command before running your code?

@mikesive
Copy link

Getting the same issue, I tried LC_ALL=en_US.UTF-8, which didn't work. I downgraded as @Kukunin suggested and the problem went away.

@zedtux
Copy link

zedtux commented Nov 29, 2016

Setting the following fixed the issue to me:

export LC_ALL=C.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

@marocchino
Copy link
Member

I checked file encoding of our project but, did not found strange things.
As ffaker use utf-8, It looks obvious to have to set lang.
but, seems docker team does not want to change default value.

For now, you need to set encoding explicitly like this:

$ docker run --rm -it -e LANG=C.UTF-8 ruby:2.4.0 bash
root@fee70e00af3c:/# gem install ffaker
Fetching: ffaker-2.4.0.gem (100%)
Successfully installed ffaker-2.4.0
1 gem installed
root@fee70e00af3c:/# irb -r ffaker

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

No branches or pull requests

7 participants