Skip to content

MariaDB client version vs. package version error #1348

@chadmyers

Description

@chadmyers

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions