gem install does not install rails - ruby-on-rails

I have this version of ruby:
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
How do I solve this error.
ERROR: Error installing rails:
The last version of nokogiri (>= 1.6) to support your Ruby & RubyGems was 1.10.9. Try installing it with gem install nokogiri -v 1.10.9 and then running the current command again
nokogiri requires Ruby version >= 2.3, < 2.7.dev. The current ruby version is 2.7.0.0.

Currently (04-02-2020) Ruby 2.7.0 on Windows is only supported in the latest release candidate of nokogiri, see their git repo.
You can (install pre-releases)[https://guides.rubygems.org/patterns/#prerelease-gems] with the --pre flag of gem:
gem install nokogiri --pre

Related

Error installing Rails 6.0.2.2 with Ruby 2.7.0.0 - The last version of nokogiri (>= 1.6) to support your Ruby & RubyGems was 1.10.9

I am on Windows and running Ruby 2.7.0.
When running gem install rails I get this error:
ERROR: Error installing rails:
The last version of nokogiri (>= 1.6) to support your Ruby & RubyGems was 1.10.9.
Try installing it with `gem install nokogiri -v 1.10.9` and then running the current command again
nokogiri requires Ruby version >= 2.3, < 2.7.dev. The current ruby version is 2.7.0.0.
When I run gem install nokogiri -v '1.10.9' I get the same exact error.
I have installed gem install nokogiri -v 1.11.0.rc1 --pre , but I'm still getting the same errors.
$ nokogiri -v
# Nokogiri (1.11.0.rc1)
---
warnings: []
nokogiri: 1.11.0.rc1
ruby:
version: 2.7.0
platform: x64-mingw32
description: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
engine: ruby
libxml:
source: packaged
patches:
- 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
- 0002-Remove-script-macro-support.patch
- 0003-Update-entities-to-remove-handling-of-ssi.patch
- 0004-libxml2.la-is-in-top_builddir.patch
compiled: 2.9.10
loaded: 2.9.10
libxslt:
source: packaged
patches: []
compiled: 1.1.34
loaded: 1.1.34
So, I understand that Ruby 2.7.0 is later than 2.7.dev, but I have the nokogiri gem installed.
Also, everything was working fine with Ruby 2.6.5. I did uninstall it, remove it from the Path, and restart my machine.
If anybody has any ideas I would love to hear them.
It seems that when you are trying to install nokogiri it installs a version which is not compatible with your ruby version and shows that error.
Even when you specify the version to install, it'll ignore the version number specified and install the latest one as shown in your error.
$ nokogiri -v
# Nokogiri (1.11.0.rc1)
---
warnings: []
nokogiri: 1.11.0.rc1
So try to make the gem makes the download itself for the currently installed ruby version.
gem install nokogiri --platform=ruby
PS This could take a while...

How do I tell bundle install to use the version of Ruby on my PATH?

I'm trying to install my Rails 5 project on Debian. Either running bundle install with or without sudo results in an error complaining about not having the appropriate version of Ruby, even though when I run ruby -v after, you can see the version is 2.4. How do I point bundle install to the right version?
$ sudo bundle install
[sudo] password for myuser:
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Your Gemfile lists the gem jquery-rails (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Using rake 12.0.0
Using concurrent-ruby 1.0.5
Using i18n 0.8.6
Using minitest 5.10.3
Using thread_safe 0.3.6
Using tzinfo 1.2.3
Gem::InstallError: activesupport requires Ruby version >= 2.2.2.
An error occurred while installing activesupport (5.0.4), and Bundler cannot continue.
Make sure that `gem install activesupport -v '5.0.4'` succeeds before bundling.
$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [armv6l-linux-eabihf]
Running without sudo:
$ bundle install
Your Gemfile lists the gem jquery-rails (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Using rake 12.0.0
Using concurrent-ruby 1.0.5
Using i18n 0.8.6
Using minitest 5.10.3
Using thread_safe 0.3.6
Using tzinfo 1.2.3
Gem::InstallError: activesupport requires Ruby version >= 2.2.2.
An error occurred while installing activesupport (5.0.4), and Bundler cannot continue.
Make sure that `gem install activesupport -v '5.0.4'` succeeds before bundling.
$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [armv6l-linux-eabihf]
When you invoke bundle, first of all bundle itself gets resolved in $PATH. You can check, where the executable of it is located by typing whereis bundle or which bundle. In my case (Ubuntu 16.04) it's located in /usr/local/bin/bundle.
If we execute cat /usr/local/bin/bundle, we will get a content of this executable:
$ cat /usr/local/bin/bundle
#!/usr/bin/ruby2.4
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0.a"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end
load Gem.activate_bin_path('bundler', 'bundle', version)
As you can see, it's a plain Ruby script, and the top most line (#!/usr/bin/ruby2.4) sets the interpreter to execute it.
I suppose, that in your case there is an old Ruby version used, because if you had a Ruby in your system before installing 2.4.0, executable for gem didn't get updated for 2.4 and also uses old Ruby version. You can check this by doing which gem (for me /usr/bin/gem) and checking file contents with cat.
After that you can check available executables of gem by typing whereis gem:
$ whereis gem
gem: /usr/bin/gem /usr/bin/gem2.2 /usr/bin/gem2.4
Then you can just remove bundler by typing gem uninstall bundler (this should also remove it's executables) and install it again using correct gem, executing:
/usr/bin/gem2.4 install bundle
That should do the trick, because in executable for bundler you will get Ruby 2.4 as interpreter.
update-alternatives command can also be useful for such cases.
As you can see, it's such a headache, so my recommendation is either to use Ruby version manager (rvm, rbenv, etc.), or have only one Ruby version per machine.
gem install rails --version 5.0.0

How to install the Nokogiri gem using Ruby 1.9.3

I'm using Ruby 1.9.3 with my Rails v3.2.19 application and I'm unable to run bundle because Nokogiri requires a Ruby version >= 2.1.0. At the moment I cannot upgrade my Ruby version and I really need to install Nokogiri otherwise my app won't run.
Besides the regular solutions using gem install, I've already tried the following command line with no success:
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2
ERROR:
>Error installing nokogiri:
nokogiri requires Ruby version >= 2.1.0.
Is there a way that I can install Nokogiri using my current Ruby version?
Additional Info:
Rails version - 3.2.19
Ruby version - 1.9.3
Nokogiri version - 1.7.0.1
OS - CentOS 7
The last version of nokogiri to support Ruby 1.9.3 was 1.6.8.1, so you need to do something like
gem install nokogiri -v 1.6.8.1
First try update xcode command line tools xcode-select --install
Then try these steps https://github.com/sparklemotion/nokogiri/wiki/What-to-do-if-libxml2-is-being-a-jerk

Your Ruby version is 2.2.4, but your Gemfile specified 2.3.0?

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

Installing Rails 4.2.0.beta1 - Unresolved dependency found during sorting

I've attempted to install Rails 4.2.0.beta1 (released Aug 20, 2014). I get an error "Unresolved dependency found during sorting." Here are the details:
$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
$ gem -v
2.4.1
$ gem install rails --pre
ERROR: While executing gem ... (Gem::DependencyError)
Unresolved dependency found during sorting - activesupport (>= 4.0)
(requested by sprockets-rails-3.0.0.beta1)
How can I install Rails 4.2.0.beta1?
You are using RubyGems 2.4.1:
$ gem -v
2.4.1
there's a bug with the newest 2.4.1 release of RubyGems (the system gem) that makes it difficult to install Rails 4.2.0.beta1. See Rails issue 16609.
You can work around the problem by downgrading to the 2.2.2 version of RubyGems.
$ gem update --system 2.2.2
Updating rubygems-update
Fetching: rubygems-update-2.2.2.gem (100%)
Successfully installed rubygems-update-2.2.2
Installing RubyGems 2.2.2
RubyGems 2.2.2 installed
Now you will be able to install Rails 4.2.0.beta1.
If you are using RVM, and you want to use two different versions of the RubyGems system gem, you'll need to install two different versions of the latest Ruby 2.1.2 release with different RVM names. For example, if you already have Ruby 2.1.2 installed with the newest RubyGems 2.4.1, you can install another version of Ruby 2.1.2, giving it a different name:
$ rvm install ruby-2.1.2-oldrubygem
RubyGems 2.2.2 is installed by default with the current Ruby 2.1.2 release:
$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
$ gem -v
2.2.2
You'll be able to install Rails 4.2.0.beta1.
This issue has been fixed on RubyGems. Upgrade to at least 2.4.4
Have a look at this GitHub issue for more information.

Resources