'mysql2 gem RoR in macos Monterey - first time installing RoR

Following the instructions here, i try running rake db:create and get this error:

Could not find gem 'mysql2 (~> 0.5)' in rubygems repository https://rubygems.org/ or installed locally.
The source does not contain any versions of 'mysql2'
Run `bundle install` to install missing gems.

Then, when running bundle install i get this:

Unfortunately, an unexpected error occurred, and Bundler cannot continue.

Also tried installing mysql2 gem which throws this error.

Any help on how to overcome this issue?



Solution 1:[1]

Try this

gem install mysql2 -v 0.5.3 -- --srcdir=/opt/homebrew/include/mysql/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman