Rails installation failed - ruby-on-rails

I have installed Ruby on my Windows 10 with version 2.7.1p83.
As suggested by various websites, I used gem install rails to install rails. But it is showing:
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.1.83.
Now when I write gem install nokogiri it shows
ERROR: Error installing nokogiri:
The last version of nokogiri (>= 0) to support your Ruby & RubyGems was 1.10.9. Try installing it with `gem install nokogiri -v 1.10.9`
nokogiri requires Ruby version >= 2.3, < 2.7.dev. The current ruby version is 2.7.1.83.
What could be the possible reason and how can I troubleshoot?

use the upcoming release candidate for now: v1.11.0.rc2
gem inst nokogiri --pre
or in your Gemfile
gem 'nokogiri', '>= v1.11.0.rc2'

Related

Ruby rails error: Bundler could not find compatible versions for gem "bundler":

Bundler could not find compatible versions for gem "bundler":
The error is below
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (~> 2.2)
rails (= 6.1.4.6) was resolved to 6.1.4.6, which depends on
bundler (>= 2.2.0)
Current Bundler version:
bundler (2.1.4)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (~> 2.2)', which is required by gem 'rails (= 6.1.4.6)', in any of the relevant sources:
the local ruby installation
Your solution is actually in the error message that you are getting. Run
gem install bundler
to install the latest version of bundler (that should satisfy the constraints
You can also specify a particular version of any gem by specifying the version flag. For example.
gem install bundler -v 2.2.0
gem install bundler --version 2.2.19 --default

Bundler : Is there a way to set the version?

When trying to run 'bundle install', I have this message :
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 5.0.2) was resolved to 5.0.2, which depends on
bundler (>= 1.3.0, < 2.0)
Current Bundler version:
bundler (2.1.2)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (>= 1.3.0, < 2.0)', which is required by gem 'rails (= 5.0.2)', in any of the sources.
Bundler could not find compatible versions for gem "pg":
In Gemfile:
pg (= 0.18.3)
jsonb_accessor (~> 1.0.0) was resolved to 1.0.0, which depends on
pg (>= 0.18.1)
Then, I think I need to change my bundler version why is 2.1.2, I would like to change to 1.17.3.
gem list command says :
bundler (default 1.17.3)
but bundle -v command says :
Bundler version 2.1.2
I am using ruby 2.5.1 with RVM.
Do you have any idea how to do so ?
I read that I can use bundle config set but it does nothing.
Bundler installs a binary that gets invoked before your Gemfile is read, so you'll need to remove the version you are using and install the version you want.
You can do this with RVM with the following:
rvm #global do gem uninstall bundler -a -x -I || true
gem install bundler -v '= 1.17.3'
If you hop between projects, you may have to do this a lot, or you can do this:
gem install bundler -v '= 1.17.3'
And instead of using bundle install, use:
bundle _1.17.3_ install
to specify the version of the bundler gem gets used.
I would recommend you look into upgrading Rails, not only to get on a supported version (that has security updates), but it will also allow you to upgrade bundler again.
You need to delete manually the directory on your problematic ruby version: for example if there is a bundler problem with the 2.5.1 ruby version, go to this path:
/Users/YOUR_USER/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/
and delete the bundler directory.
If bundler is in the default specification you also need to remove the bundler associated file on this path:
/Users/YOUR_USER/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/specifications/default
Then you can re-install a specific version of bundler using #Unixmonkey answer

How do I get Rails 5.0.6 working on Windows with Ruby 2.4 and Nokogiri 1.8.1?

I upgraded Ruby from 2.3 to 2.4. When I run bundle, I get
C:\Users\Chloe\workspace>bundle
Fetching gem metadata from https://rubygems.org/.........
Gem::InstallError: nokogiri requires Ruby version < 2.4, >= 2.1.0.
An error occurred while installing nokogiri (1.7.0.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.7.0.1'` succeeds before bundling.
In Gemfile:
nested_form_fields was resolved to 0.8.2, which depends on
rails was resolved to 5.0.2, which depends on
actioncable was resolved to 5.0.2, which depends on
actionpack was resolved to 5.0.2, which depends on
actionview was resolved to 5.0.2, which depends on
rails-dom-testing was resolved to 2.0.2, which depends on
nokogiri
However, I was able to install Rails manually with gem install rails --version 5.0.6. It installed Nokogiri 1.8.1. (I also installed, then removed Rails 5.0.2.)
C:\Users\Chloe\workspace>gem list nokogiri
*** LOCAL GEMS ***
nokogiri (1.8.1 x64-mingw32)
However, bundle and rails -v still won't work.
C:\Users\Chloe\workspace>rails -v
Could not find nokogiri-1.7.0.1-x64-mingw32 in any of the sources
Run `bundle install` to install missing gems.
Gemfile
gem 'rails', '~> 5.0.2'
ruby '~> 2.4.0'
...
I don't know how to prove this since the nokogiri team does not release a gemspec, but that version of nokogiri may not support ruby 2.4 on Windows.
Take a look at:
https://github.com/sparklemotion/nokogiri/blob/v1.7.1/.cross_rubies. IT does not include ruby 2.4.x.
If you absolutely need to upgrade to ruby 2.4 try locking nokogiri version on 1.8.1, which seems to support ruby 2.4 on windows as per https://github.com/sparklemotion/nokogiri/blob/v1.8.1/.cross_rubies
gem 'nokogiri', '1.8.1'

Gem::InstallError: nokogiri requires Ruby version < 2.4, >= 2.1.0. rails

After running rails new demo I get the following error:
Gem::InstallError: nokogiri requires Ruby version < 2.4, >= 2.1.0.
An error occurred while installing nokogiri (1.7.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.7.1'` succeeds before bundling.
My Ruby version is 1.9.3. I could update ruby but I'm worried that may create even more problems. Any suggestions?
More Information:
The Nokogiri gem is not listed in my Gemfile, if I run gem list it includes nokogiri (1.6.8.1 x86-mingw32, 1.6.6.2 x86-mingw32, 1.6.1 x86-mingw32)
You need to downgrade the version of nokogiri to ~> 1.6.8
change nokogiri version in Gemfile
gem 'nokogiri', '~> 1.6.8'
Dependency for nokogiri version 1.6.8 is ruby >= 1.9.2 https://rubygems.org/gems/nokogiri/versions/1.6.8
But it is changed for nokogiri version 1.7.1 to ruby >= 2.1.0 https://rubygems.org/gems/nokogiri/versions/1.7.1

use nokogiri 1.5.9 with rails

I want to use Ruby 1.8.7 with Rails, but when I run bundle install I get this error:
Gem::InstallError: nokogiri requires Ruby version >= 1.9.2.
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.
nokogiri 1.6.0 does not support Ruby <1.9.2.
I tried installing nokogiri 1.5.9 to make things work but it did not help.
i added the line
gem 'nokogiri', '~> 1.5.10'
in my Gemfile and it install nokogiri 1.5.10 and the bundle install succeeded !
According to the changelog:
1.5.0 beta1 / 2010/05/22
Ruby 1.8.6 is deprecated. Nokogiri will install, but official support is ended.
So, you'll probably need to use nokogirl version 1.4.7.

Resources