mysql2: MariaDB client version vs. package version error
Ruby: 3.1.3.1 Platform: Windows, msys2, mingw64 MariaDB Connector/C version: 3.3.8 mysql2 gem version: 0.5.5
My MariaDB client lib install command:
ridk exec sh -c "pacman -S --needed --noconfirm mingw-w64-x86_64-libmariadbclient"
My Gem install command:
& C:\tools\ruby31\bin\gem.cmd install mysql2 --no-document --no-post-install-message -q -- --with-mysql-lib=C:\tools\msys64\mingw64\lib --with-mysql-include=C:\tools\msys64\mingw64\include
I’ve also tried with the same effect:
& C:\tools\ruby31\bin\gem.cmd install mysql2 --no-document --no-post-install-message -q -- --with-mysql-dir=C:\tools\msys64\mingw64
I can successfully gem install/compile the mysql2 gem but when I try to use it, I get the error:
Gem Load Error is: Incorrect MySQL client library version! This gem was compiled for 10.8.8 but the client library is 3.3.8.
I noticed in mysql2/ext/mysql2/client.c file it has (lines 52-58)
#if defined(MARIADB_CLIENT_VERSION_STR)
#define MYSQL_LINK_VERSION MARIADB_CLIENT_VERSION_STR
#elif defined(LIBMYSQL_VERSION)
#define MYSQL_LINK_VERSION LIBMYSQL_VERSION
#else
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
#endif
Then (lines 1514 - 1526):
const char *lib = mysql_get_client_info();
...
if (lib[i] != MYSQL_LINK_VERSION[i]) {
rb_raise(rb_eRuntimeError, "Incorrect MySQL client library version! This gem was compiled for %s but the client library is %s.", MYSQL_LINK_VERSION, lib);
My msys64\mingw64\include\mysql\mariadb_version.h file has:
#define MARIADB_CLIENT_VERSION_STR "10.8.8"
...
#define MARIADB_PACKAGE_VERSION "3.3.8"
MariaDB client’s mysql_get_client_info() function returns MARIADB_PACKAGE_VERSION, but mysql2 gem is comparing that against the MARIADB_CLIENT_VERSION_STR.
What I don’t understand is that this stuff has been there for 3 years, but my mysql2 gem installation only just started breaking within the last 30 days or so. It worked in December when I rebuilt an AMI in AWS using the latest mysql2 gem (0.5.4) and MariaDB client (I think it was 3.3.7 or maybe 3.3.8).
Any thoughts on why this worked and why it’s not working now? Thanks in advance!
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 2
- Comments: 16
git clone https://github.com/brianmario/mysql2.gitcd mysql2git checkout 0.5.6cd extopen client.c and comment the following line
go to the project root dir and do
gem build mysql2.gemspeccopy mysql2-0.5.6.gem to your rails project folder and do
gem install mysql2-0.5.6.gem -- --with-mysql-dir="E:\Ruby32-x64"(assumed libmysql.dll is already in this folder)Same to me. What I did:
if (lib[i] != MYSQL_LINK_VERSION[i]) { ... }My command to install mysql2 is
gem install mysql2-0.5.6.gem --platform=ruby – ‘–with-mysql-lib=“C:\Program%20Files\MySQL\MySQL%20Server%205.7\lib” --with-mysql-include=“C:\Program%20Files\MySQL\MySQL%20Server%205.7\include” --with-mysql-dir=“C:\Program%20Files\MySQL\MySQL%20Server%205.7”’
MySQL is installed at
C:\Program Files\MySQL\MySQL Server 5.7.Still an issue on my Windows 10 system that’s using Ruby33 64bit. Mine is very similar to @radox83’s issue. I get the error:
Incorrect MySQL client library version! This gem was compiled for 10.8.8 but the client library is 3.4.3.I’ve tried re-downloading Ruby as well as its MSYS2 toolchain.I’ve tried downloading this stupid gem for 6 hours today through the dozens of different combinations + ways that people have suggested online. Every solution either 1) changes the version of the compiled gem, 2) changes the version of the client library, or 3) nothing. I can NOT get the client and gem version to match.
test.rbcode used for all installation attempts below:Commands used to run
test.rbcode above:ruby test.rbbundle exec ruby test.rbInstallation attempts (after each attempt I made sure to uninstall the mysql2 gem and any programs I downloaded for that attempt and I deleted the Gemfile.lock and did
bundle):gem install mysql2by itself.gem install mysql2 -- --with-mysql-dir="DIRECTORY/TO/EXTRACTION"gem install mysql2 -- --with-mysql-dir="DIRECTORY/TO/EXTRACTION"gem install mysql2 -- --with-mysql-dir="DIRECTORY/TO/EXTRACTION"gem install mysql2 -- --with-mysql-dir="DIRECTORY/TO/SQL_DOWNLOAD_LOCATION"gem install mysql2 -- --with-mysql-dir="DIRECTORY/TO/MARIA_DOWNLOAD_LOCATION"gem install mysql2 -- --with-mysql-dir="DIRECTORY/TO/MARIA_DOWNLOAD_LOCATION"gem install mysql2 -- --with-mysql-dir="DIRECTORY/TO/MARIA_DOWNLOAD_LOCATION"ridk exec gem install mysql2 --platform=ruby -- --use-system-librariesby itself.gem install mysql2 -- --with-mysql-config="DIRECTORY_TO_MARIADB_CONFIG"on 1 or 2 of the mariadb installations mentioned above.gem install mysql2 -- --with-mysql-dir="C:\Ruby33-x64\msys64"None of this worked. I don’t understand how this can be so difficult when the mysql2 gem simply says to do
gem install mysql2and the RubyInstaller makes a big deal out of how they uses MSYS2 to build C/C++ extensions and it doesn’t even work properly.Hello @Whaat , almost correct but I suggest to
gem fetch,gem build mysql2.gemspecgem install mysql2.gemThis to avoid starting from source code, that for sure has additional building steps, deps, etc… Hope it helps you!