From: "drbrain (Eric Hodel)" Date: 2012-10-25T09:12:38+09:00 Subject: [ruby-core:48214] [ruby-trunk - Bug #7211] eval does not respect encoding magic comment Issue #7211 has been updated by drbrain (Eric Hodel). =begin Even without irb the description does not make sense. The code used on line 907 is read as UTF-8 on line 899, so the following would be the equivalent and works correctly: $ LANG=C ruby19 -ve 'eval File.read("t.rb", mode: "r:UTF-8:-")' ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin12.2.0] �� $ cat t.rb puts '��' $ LANG=C ruby19 -ve 'eval File.read("t.rb", mode: "r:UTF-8:-")' ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin12.2.0] �� Note that reading without UTF-8 results in a SyntaxError, not an ArgumentError. $ LANG=C ruby19 -ve 'eval File.read("t.rb")' ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin12.2.0] -e:1:in `eval': (eval):1: invalid multibyte char (US-ASCII) (SyntaxError) (eval):1: invalid multibyte char (US-ASCII) from -e:1:in `
' I think you will need to file a bug against RubyGems including the backtrace and your gemspec: `gem build --backtrace ���` =end ---------------------------------------- Bug #7211: eval does not respect encoding magic comment https://bugs.ruby-lang.org/issues/7211#change-31479 Author: vo.x (Vit Ondruch) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux] =begin This should work IMO. $ LANG=C irb irb(main):001:0> eval <' I am currently bitten by this behavior in RubyGems. I have .gemspec [1], which have some UTF-8 characters, with the encoding magic comment. While building gem, RubyGems evals the .gemspec code [1], where the magic comment is ignored and build fails: $ LANG=C gem build gem-nice-install.gemspec ERROR: While executing gem ... (ArgumentError) invalid byte sequence in US-ASCII [1] https://gist.github.com/3944821 [2] https://github.com/rubygems/rubygems/blob/master/lib/rubygems/specification.rb#L907 =end -- http://bugs.ruby-lang.org/