Help us understand the problem. What is going on with this article?

Macでirbしたところ日本語入力できなかった

More than 1 year has passed since last update.

はじめに

irbで"こんにちは"を入力してみたところ…

irb(main):001:0> a = "\U+FFE3\U+FFE3\U+FFE3\U+FFAB\U+FFE3\U+FFA1\U+FFE3\U+FFAF"
=> ""

なぁにこれぇ

原因

irbがコマンド入力を受け取る際に使っているMac付属のライブラリ(libedit)が日本語に対応していないのが原因らしい

解決

日本語対応のライブラリ(readline)に切り替える

readlineをインストール

$ brew install readline

readlineにパスを通す

$ brew link readline --force

readlineを通してRubyをインストールするようにする

$ RUBY_CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline)"

Rubyの再インストール

$ rbenv uninstall 2.5.3
$ rbenv install 2.5.3

結果

irb(main):001:0>  a = "こんにちは"
=> "こんにちは"

参考

日本語が使えるirbにしておく - ザリガニが見ていた...。
rails cで日本語が通らないときの直し方
Homebrew導入~Ruby on rails開発構築環境まとめ

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away