6
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2018-11-25

#はじめに
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で日本語が通らないときの直し方]
(https://qiita.com/irohiroki/items/c82657b5cb4bdb2aaac4)
Homebrew導入~Ruby on rails開発構築環境まとめ

6
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?