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

UndefinedConversionError when LANG and default encoding are different #1023

Open
tompng opened this issue Oct 19, 2024 · 0 comments
Open

UndefinedConversionError when LANG and default encoding are different #1023

tompng opened this issue Oct 19, 2024 · 0 comments

Comments

@tompng
Copy link
Member

tompng commented Oct 19, 2024

Description

In this situation, IRB raises UndefinedConversionError

[tomoya.ishida:3.2]% echo "IRB.conf[:USE_MULTILINE]=false" > irbrc
[tomoya.ishida:3.2]% IRBRC=irbrc LANG=en_US.ASCII ruby -Eutf-8:utf-8 -e "binding.irb"              
irb(main):001> Readline::VERSION
=> "8.2"
irb(main):002> \343\201\202\343\201\202\343\201\202
/Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb/history.rb:82:in `write': "\xE3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII (Encoding::UndefinedConversionError)
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb/history.rb:82:in `puts'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb/history.rb:82:in `block in save_history'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb/history.rb:73:in `open'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb/history.rb:73:in `save_history'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1033:in `ensure in run'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1034:in `run'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1587:in `irb'
	from <internal:prelude>:5:in `irb'
	from -e:1:in `<main>'
/Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb/context.rb:628:in `strip': invalid byte sequence in US-ASCII (Encoding::CompatibilityError)
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb/context.rb:628:in `parse_command'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1134:in `build_statement'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1122:in `block in each_top_level_statement'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1119:in `loop'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1119:in `each_top_level_statement'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1042:in `eval_input'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1023:in `block in run'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1022:in `catch'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1022:in `run'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.14.1/lib/irb.rb:1587:in `irb'
	from <internal:prelude>:5:in `irb'
	from -e:1:in `<main>'

Similar thing might happen in a situation described in ruby/reline#755 (comment)

Result of irb_info

Ruby version: 3.2.2
IRB version: irb 1.14.1 (2024-09-25)
InputMethod: ReadlineInputMethod with ext/readline 8.2
Completion: RegexpCompletor
.irbrc paths: irbrc, /Users/tomoya.ishida/github/ruby/3.2/irbrc
RUBY_PLATFORM: arm64-darwin22
LANG env: en_US.ASCII
East Asian Ambiguous Width: 1

Terminal Emulator

Terminal.app

Setting Files

irbrc

IRB.conf[:USE_MULTILINE]=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant