How to install mysql2 with new Ruby Version? - ruby-on-rails

I have built an application a few month ago. I downloaded it from Github and I tried to launch it with rails s but I got this error :
'require': cannot load such file -- mysql2/2.6/mysql2
I tried to install it with gem install mysql2
But I get this error :
The last version of mysql2 (>= 0) to support your Ruby & RubyGems was
0.5.2. Try installing it with gem install mysql2 -v 0.5.2
mysql2 requires Ruby version >= 2.0, < 2.6. The current ruby version is 2.6.4.104.
When i tried to do the command suggested with -v 0.5.2 I got the same error.
Does anyone have a solution?
I am on Windows and I don't have rbenv installed.
My Ruby version : ruby 2.6.4p104 (2019-08-28 revision 67798) [x64-mingw32]

Download the gem file manually and installing works
gem i mysql2-0.5.2.gem
Temporarily enhancing PATH for MSYS/MINGW...
Installing required msys2 packages: mingw-w64-x86_64-libmariadbclient
Building native extensions. This could take a while...
Successfully installed mysql2-0.5.2
Parsing documentation for mysql2-0.5.2
Installing ri documentation for mysql2-0.5.2
Done installing documentation for mysql2 after 1 seconds
1 gem installed
Source: https://github.com/brianmario/mysql2/issues/1021

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

gem install does not install 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

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)

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

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