Rbenv: cannot load such file -- irb

Created on 21 May 2019  路  4Comments  路  Source: rbenv/rbenv

Hello,
I recently installed a fresh installation of Ubuntu, and used this guide to install rbenv: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-18-04

Ever since, irb command is not working.
It appeared to be installed:

maayan@maayan:~/apps/makerspro$ which irb
/home/maayan/.rbenv/shims/irb
maayan@maayan:~/apps/makerspro$ rbenv which irb
/home/maayan/.rbenv/versions/2.6.3/bin/irb

but this is the output I get:

maayan@maayan:~/apps/makerspro$ irb
Traceback (most recent call last):
1: from /home/maayan/.rbenv/versions/2.6.3/bin/irb:23:in <main>' /home/maayan/.rbenv/versions/2.6.3/bin/irb:23:inload': cannot load such file -- /home/maayan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb (LoadError)

Most helpful comment

Does the file referenced in the error message exist?

$ file ~/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb
/Users/mislav/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb: Ruby script text executable, ASCII text

If not, it sounds like a broken Ruby 2.6.3 installation. I'm not sure how that could have happened during rbenv install 2.6.3, unless it exited with an error. Did you notice anything off during the installation?

In any case, this is not a bug with rbenv. If anything, it's a bug with Ruby's own installer and its default gems. Try this to fix it:

RBENV_VERSION=2.6.3 gem install irb

All 4 comments

Does the file referenced in the error message exist?

$ file ~/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb
/Users/mislav/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb: Ruby script text executable, ASCII text

If not, it sounds like a broken Ruby 2.6.3 installation. I'm not sure how that could have happened during rbenv install 2.6.3, unless it exited with an error. Did you notice anything off during the installation?

In any case, this is not a bug with rbenv. If anything, it's a bug with Ruby's own installer and its default gems. Try this to fix it:

RBENV_VERSION=2.6.3 gem install irb

Thank you so much, Mislav!
I didn't notice anything off in the installation, but installing it manually with the command your provided did the trick.
My apologies :)

Hi, I tried the solution above and it gave the following error:
Screenshot from 2020-05-24 02-59-22

Hi, I tried the solution above and it gave the following error:

So did I. For me the following isntructions solved the problem:

rbenv uninstall 2.7.0
rbenv install 2.7.0

I am running Ubuntu 18.04.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChrisBrettCA picture ChrisBrettCA  路  4Comments

kaikuchn picture kaikuchn  路  5Comments

ponamute picture ponamute  路  4Comments

wakproductions picture wakproductions  路  4Comments

codfather picture codfather  路  3Comments