LoginSignup
0
0

More than 3 years have passed since last update.

【Ruby】irbが動作しなくなったお話。【エラー】

Last updated at Posted at 2021-02-27

先日、irbを起動させようと思ったら、、、

~ $ irb
/usr/local/Cellar/rbenv/1.1.2/libexec/rbenv-exec: /Users/inouesyo/.rbenv/versions/2.6.6/bin/irb: /Users/inoueshou/.rbenv/versions/2.6.6/bin/ruby: bad interpreter: No such file or directory
/usr/local/Cellar/rbenv/1.1.2/libexec/rbenv-exec: line 47: /Users/inouesyo/.rbenv/versions/2.6.6/bin/irb: Undefined error: 0

という表示が出て起動できず。
エラーを読むに原因は恐らく、以前にホームディレクトリの名前を変更したのでそれが原因でパスが通ってないのかな?と推測。

と言うことで、user/Users/inouesyo/.rbenv/versions/2.6.6/bin/irb:のirbファイルを編集する。
irbファイルはUNIX実行ファイルとなっているため、右クリック→このアプリケーションで開く→からテキストエディタで開く。
すると

irb
#!/Users/inoueshou/.rbenv/versions/2.6.6/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'irb' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

str = ARGV.first
if str
  str = str.b[/\A_(.*)_\z/, 1]
  if str and Gem::Version.correct?(str)
    version = str
    ARGV.shift
  end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('irb', 'irb', version)
else
gem "irb", version
load Gem.bin_path("irb", "irb", version)
end

一行目のホームディレクトリの部分が以前のホームディレクトリ名になっていたので変更。

~ $ irb
irb(main):001:0> 

無事に動作し一安心。

0
0
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
0
0