OSx v12.4
Ruby v2.6.0
XCode v13.4.1
`mysql2` gem, SHA e9c662912dc3bd3707e6c7f0c75e591294cffe12
I cloned the mysql2
repo and I'm trying to run ruby benchmark/active_record.rb
from the root directory. I'm getting the following error:
/Users/richiethomas/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/activesupport-
6.1.6/lib/active_support/dependencies.rb:332:in `require': Could not load the 'mysql'
Active Record adapter. Ensure that the adapter is spelled correctly in
config/database.yml and that you've added the necessary adapter gem to your Gemfile.
(LoadError)
I see the following in the repo's Gemfile
:
group :benchmarks, optional: true do
gem 'activerecord', '>= 3.0'
gem 'benchmark-ips'
gem 'do_mysql'
gem 'faker'
# The installation of the mysql latest version 2.9.1 fails on Ruby >= 2.4.
gem 'mysql' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4')
gem 'sequel'
end
I tried running bundle install --with=benchmarks
, and that completes successfully, however it doesn't install the mysql
ActiveRecord adapter because my Ruby version is 2.6.0.
Although I know this shouldn't be necessary, I tried installing the mysql
gem via the following command, as per the gem's README.md
file:
gem install mysql2 -- --with-mysql-dir=-/usr/local/opt/mysql@5.7
However, here I get:
library not found for -lssl
clang: error: linker command failed with exit code 1
I also tried installing mysql
using the following command, as per this StackOverflow answer:
gem install mysql -- --with-ldflags=-L/usr/local/opt/openssl/lib
However, I get an error related to rb_cFixnum
, which I surmise is because the Fixnum
class doesn't exist in my Ruby version (it appears to have been eliminated in 2.4.0, and I'm on 2.6.0). Between these two errors, I feel like I can eliminate the possibility that the error is caused by a lack of the mysql
gem.
On the chance that the root issue is an out-of-date linker file, I have updated both my OS and XCode to the latest versions available as of today's date. The above errors occurred after I completed this update process.
My question is two-fold:
I notice that the error message references
config/database.yml
, which I'm accustomed to seeing in my Rails projects but which I don't see anywhere in themysql2
repo. Does this mean I can only run the benchmarks if there's an associateddatabase.yml
file? And if so, how would I run these benchmarks from (for example) a "Hello World"-type Rails project?If I'm unable to install the
mysql
gem in conjunction with Ruby versions greater than 2.4.0, why does thebenchmarks/active_record.rb
file appear to rely on its presence in this line of code? I would expect to be able to run benchmark files regardless of my Ruby version.