Project

General

Profile

Actions

Bug #7211

closed

eval does not respect encoding magic comment

Added by vo.x (Vit Ondruch) over 11 years ago. Updated over 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]
Backport:
[ruby-core:48188]

Description

=begin
This should work IMO.

$ LANG=C irb
irb(main):001:0> eval <<EOF
irb(main):002:0" # encoding: utf-8
irb(main):003:0" puts "vít"
irb(main):004:0" EOF
SyntaxError: (irb):3: invalid multibyte char (US-ASCII)
(irb):1: syntax error, unexpected $end, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
from /usr/bin/irb:12:in `'

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0