Rails: Undefined method `in_pasting?' for Reline::ANSI:Class (NoMethodError)

Viewed 708

I have Ruby 2.7.2 and Rails 6.1.3.1 installed on my Ubuntu 20.04 machine. However, when I try to test a ruby command using the command below:

irb
a = 1

I get the error below:

/home/mycomputer/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.3.5/lib/irb/ruby-lex.rb:50:in block in set_input': undefined method in_pasting?' for Reline::ANSI:Class (NoMethodError)

I am still tryring to fix it, but it's working.

1 Answers

The error was caused by an issue with the reline gem in the Ruby 2.7.2 setup. However, if I switch to another Ruby version (2.6.6) using rbenv global 2.6.6 everything seems to work fine.

Here's how I fixed it:

Solution 1:

Since the reline gem comes with Ruby installations, we will uninstall the ruby 2.7.2 version that is the cause of the issue using rbenv :

rbenv uninstall 2.7.2

Next, reinstall the ruby 2.7.2 version that is the cause of the issue using rbenv :

rbenv install 2.7.2

Afterwhich you will install the version of Bunder and Rails that you are using. In this case, my Rails version is Rails 6.1.3.1:

gem install bundler
gem install rails -v 6.1.3.1
rbenv rehash

You can afterwards, check the version of ruby, bundler and rails that were installed using the command below:

ruby -v
bundler -v
rails -v

This time when you try to test again using irb it should work fine.

Solution 2:

A faster approach will be to uninstall the reline gem in the Ruby 2.7.2 setup using the command below:

gem uninstall reline

And then reinstall it:

gem install reline

Note:

I did not test this to confirm if it fixes the issue.

That's all.

I hope this helps

Related