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.
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
Yesterday I updated my Ruby version to 2.6.5 with rbenv, but today I had a problem when I wanted to update Rails to 6.0.2.1.
It didn't work well.
This is what I have:
echo $PATH
/usr/local/opt/ruby/bin:./bin:./node_modules/.bin:/Users/paulinedussart/.rbenv/shims:/Users/paulinedussart/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/Users/paulinedussart/.rvm/bin
ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
which ruby
/usr/local/opt/ruby/bin/ruby
I did:
gem install rails
I got:
Successfully installed rails-6.0.2.1
Parsing documentation for rails-6.0.2.1
Done installing documentation for rails after 0 seconds
1 gem installed
then rbenv rehash.
When I ran which rails or which -a rails I got:
/usr/bin/rails
To check if everything was ok I ran rails --version but the result was:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
but I did not do that.
Somewhere I saw this instruction
ls `rbenv prefix`/bin
to check if Rails was there but it doesn't appear:
bundle bundler erb gem irb rake rdoc ri ruby
Finally, when I run gem list rails I get:
*** LOCAL GEMS ***
rails (6.0.2.1)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.3.0)
sprockets-rails (3.2.1)
I obviously closed the terminal at a different step of the config but without success.
I'm sure there is a problem with folders but I don't know how to fix this to put the gem rails in the correct one.
Does somebody have an idea?
Try this:
Switch to Ruby 2.6.5:
rbenv global 2.6.5
Install the Bundler gem:
gem install bundler
Install Rails:
gem install rails
Try using: rbenv rehash.
Also you can check "Rails is not currently installed on this system - High Sierra #1106".
I had the same issue and I refered to this issue and found we don't need:
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
You just need:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
if you install it via Homebrew.
While attempting to solve another issue identified in this thread:
Error while trying to load the gem 'devise. ActiveSupport: Duration can't be coerced into Integer, I followed the suggested solution and changed my ruby version from 2.4.1 to 2.3.3 using rbenv. I also made similar changes in my Gemfile to reflect the new ruby version. However, when I tried to bundle install again, it throws an error saying that my ruby version is 2.4.1, when my Gem specified 2.3.3. However, running ruby -v shows my ruby version is on 2.3.3.
$ bundle install
Your Ruby version is 2.4.1, but your Gemfile specified 2.3.3
$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
Any help here would be appreciated. Thank you!
Gem installation is specific to ruby version, so the bundler you're using is likely installed to your old ruby. Try installing bundler again:
gem install bundler
That should fix your problem.
Im facing this problem when i'm installing bunder using command "bunlde install"
Initially i tried solving this issue by using following command
gem install autoprefixer-rails -v '6.2.2'
but again it said "autoprefixer-rails requires ruby version >= 2.0."
when i type
"ruby -v", my ruby version shows 2.3.0.
Next i have tried adding
ruby '2.3.0' to my gem file, then there was a conflict saying your ruby version is 1.9.3 but your gem file has 2.3.0
Need help how to proceed further.
Change your ruby version in the system first. If you using rvm then use following command.
rvm use 2.3.0
If you don't have it then install it by following command
rvm install 2.3.0
Delete the Gemfile.lock file and run
bundle install
Hopefully it will work. Thank you
I'm trying to bundle install a ruby project in Git Bash but I'm getting the above message.
ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [i836-mingw32]
gem -v
2.3.0
New to Ruby so its really frustrating. I'm trying to do the project below
http://www.viralrails.com/?p=25
This happens because you are specifying a Ruby version in your Gemfile (2.3.0) and this version is not installed or is not the current or default version.
Don't remove the line ruby '2.3.0' as someone said above. You app may have dependencies to this version. Do the following:
1) Check if you have Ruby 2.3.0 installed. If you are using rvm this may be done by
rvm list
and if you are using rbenv by
rbenv versions
2) If you don't have this Ruby version in your list of installed versions, then install it by issuing the following command
rvm install 2.3.0
and if you are using rbenv by
rbenv install 2.3.0
3) If you already had Ruby 2.3.0 installed or completed step 2 above, enter your app directory and issue the following command
rvm use 2.3.0
and if you are using rbenv by
rbenv local 2.3.0
Then run
bundle install
and I believe things will be ok.
Hope it helps!
Install bundler after installing ruby 2.4.0.
gem install bundler
If you installed bundler before installing ruby 2.4.0 then you should reinstall bundler or update it.
Also if the above command didn't work.
gem update bundler
I try to install skylinecms but I have a problem with installing the gem.
The gem factory_girl asked me to use version> = 1.9.2 of Ruby
atmoner#atmoner:~/base_ror$ sudo gem install skylinecms
ERROR: Error installing skylinecms:
factory_girl requires Ruby version >= 1.9.2.
ruby -v
atmoner#atmoner:~/base_ror$ ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]
I have tried to change ruby version to 1.9.2
atmoner#atmoner:~/base_ror$ rvm use 1.9.2
Using /home/atmoner/.rvm/gems/ruby-1.9.2-p320
But still same problem
atmoner#atmoner:~/base_ror$ sudo gem install skylinecms
ERROR: Error installing skylinecms:
factory_girl requires Ruby version >= 1.9.2.
what's the source of this problem?
you have an idea?
You shouldn't use sudo with rvm, as it creates a new subshell with a completely new environment. See more about sudo and rvm here: RVM and 'sudo'
Most likely your system ruby version is 1.8.7, and that is what is getting invoked when you run sudo gem install skylinecms. You can verify that with the following commands:
rvm use system
ruby -v
Try installing the skylinecms gem without sudo.
Best to use per-project gemsets as suggested in rvm best practices