How to install the Nokogiri gem using Ruby 1.9.3 - ruby-on-rails

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

Related

Trying to run rails server but it is looking for a deprecated gem

In command prompt I run
rails server
and it gives me the error: "could not find nokogiri -1.10.0 in any of the sources"
I then go to install the gem:
gem install nokogiri -v 1.10.0
and git gives me the error: "The last version of nokogiri (=1.10.0) to support your Ruby & RubyGems was 1.10.0. nokogiri requires Ruby version >= 2.3, < 2.7.dev. The current version is 2.7.2.137
How do I get around this issue?
Also, I'm sure I'm going to run into a similar problem again every time I try to run
rails server
It keeps telling me there is a missing gem which tells me me there is something wrong with the install. I have uninstalled and reinstalled Ruby multiple times but the issue doesn't get resolved. Help with my first question would be great but help with my overarching issue would be even more appreciated.
Thanks,
The version of Nokogiri you try to install is not compatible with the latest version of Ruby. You have two options:
Downgrade Ruby to <= 2.6.6 or
Upgrade Nokogiri to >= 1.10.4
It depends on your application which option to choose.
I would prefer upgrading Nokogiri to the latest version. To do so change the version of Nokogiri in your Gemfile to 1.10.10 and run
$ gem install nokogiri -v 1.10.10
$ bundle update nokogiri

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...

Error installing pg, requires Ruby version >= 2.2

gem install pg
ERROR: Error installing pg:
pg requires Ruby version >= 2.2.
This happened after I installed a newer version of PG on my system, so I figure that's fine, what's happening is that it's installing gem pg using the config from the newer version of Postgres that I installed with Homebrew.
So I figure I'll just install the gem using the older version of PG that I had before.
brew install postgresql#9.6
Error: postgresql#9.6 9.6.14 is already installed
Ok perfect! So I then located the pg_config file and am trying to install the gem pg using that config:
gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql#9.6/9.6.14/bin/pg_config
ERROR: Error installing pg:
pg requires Ruby version >= 2.2.
Yet the error persists... any help appreciated... I've tried uninstalling/reinstalling PG a number of times now...
Also something else that's super frustrating... is there a list somewhere that shows what versions of PG are compatible with which versions of Ruby? I feel like every few months I run into this problem and have this frustrating search happening...
ruby --version
> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
which ruby
> /Users/jamesdong/.rvm/rubies/ruby-2.1.2/bin/ruby
which gem
> /Users/jamesdong/.rvm/rubies/ruby-2.1.2/bin/gem
According to the Changelog, pg 1.2.0 removed support for Ruby <= 2.2. Since you're using 2.1 you'll want to gem install pg -v 1.1.4, the previous version
(I don't think the actual postgres version you're using should matter as much, 1.1.4 appears to support at least up to 11.x)

ERROR: Error installing rails on ubuntu

I'm getting the following error:
ERROR: Error installing rails:
mime-types-data requires Ruby version >= 2.0.
This happens while installing Rails on Ubuntu using the command:
sudo gem install rails
How can I fix this?
As the error suggests, you need Ruby version 2.0 or later.
You are probably using system ruby. Not sure about Ubuntu 16, but earlier versions used to come with Ruby v1.9.3. You can check your current Ruby version by running the following code in your terminal:
ruby -v
For easier rubies version management, I would highly suggest to use one of the popular ruby version managers:
RVM
rbenv
Install rvm and then install latest stable version.
# Using rvm
rvm install 2.3
# Using rbenv
rbenv install 2.3
The current ruby version in your system is below 2.0.
Try installing ruby 2.0 or higher versions before installing rails.
That will solve the problem.
I was facing the same problem trying to install rails with sudo.
I was getting: ERROR: Error installing mime-types-data: mime-types-data requires Ruby version >= 2.0
The thing is ruby -v gives me ruby 2.2.3p173 while sudo ruby -v gives me ruby 1.9.3p484.
So instead of sudo gem install rails I just did gem install rails and it worked.
Error: mime-types-data requires Ruby version >= 2.0
Notice: You shouldn't install rails with sudo permission.

An error occurred while installing autoprefixer-rails (6.2.2). Additionally it say's "autoprefixer-rails requires ruby version >= 2.0. "

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

Resources