我尝试使用ocra gem将示例ruby脚本转换为可执行文件。这是我的ruby脚本。
puts "Hello word"
运行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)>'
我的ruby 版本
ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
有没有一种将ruby脚本转换为可执行文件的好方法?
问题是我的Window用户名包含字符è。就像卡斯珀提到的,UFT-8必须受到ocra的尊重。我按照这个链接解决了我的问题,然后重新启动了ocra,问题得到了解决。
更改windows 10 上的用户名