invalid byte sequence in UTF-8 (ArgumentError) with ocra

161 views Asked by At

I try to convert a sample ruby script to an executable file with the ocra gem.Here is my ruby script.

puts "Hello word"

Gives me the following error when running ocra test.rb

C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:34:in `tr': invalid byte sequence in UTF-8 (ArgumentError)
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:34:in `to_posix'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:57:in `subpath?'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:611:in `block (2 levels) in find_gem_files'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:609:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:609:in `block in find_gem_files'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:597:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:597:in `find_gem_files'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:755:in `build_exe'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ocra-1.3.11/bin/ocra:1231:in `block in <top (required)>'

My version of ruby

ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]

Is there a good way to convert a ruby script to an executable file ?

1

There are 1 answers

0
Damien On

The issue was my Window username contained the character รจ. Like Casper mentioned, UFT-8 must be respected with ocra. I followed this link to solve my problem and then restarted ocra and the issue was fixed.

Change user name on windows 10