From 2e5207b078e90cd2838df842f580e8ff9c70d497 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 23 Jul 2026 14:13:11 +0000 Subject: [PATCH] fix(mariadb plugin): wrap mysql/mariadb clients with project socket (#2522) The MariaDB client does not honor the MYSQL_UNIX_PORT environment variable, so `devbox run mariadb` (or `mysql`) falls back to its compile-time default socket (e.g. /run/mysqld/mysqld.sock) instead of the project's socket at $MYSQL_UNIX_PORT. This differs from the MySQL plugin, whose client does honor the env var. Wrap the `mysql` and `mariadb` client binaries in the plugin's flake so they default to `--socket=$MYSQL_UNIX_PORT`, mirroring how the daemon binaries are already wrapped. Each wrap is guarded by an existence check since the available client names vary across MariaDB versions, and `--add-flags` still lets users override the socket explicitly. Fixes #2522 Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01D8QQU1dVaNycyxQWcRyBhs --- plugins/mariadb/flake.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/mariadb/flake.nix b/plugins/mariadb/flake.nix index 1ac539e6357..7a339c75c0d 100644 --- a/plugins/mariadb/flake.nix +++ b/plugins/mariadb/flake.nix @@ -28,6 +28,21 @@ --add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT'; fi + # Point the client binaries at the project's socket. Unlike the MySQL + # client, the MariaDB client does not honor the MYSQL_UNIX_PORT + # environment variable, so without this it falls back to its + # compile-time default (e.g. /run/mysqld/mysqld.sock). + # https://github.com/jetify-com/devbox/issues/2522 + if [ -e "$out/bin/mysql" ]; then + wrapProgram "$out/bin/mysql" \ + --add-flags '--socket=''$MYSQL_UNIX_PORT'; + fi + + if [ -e "$out/bin/mariadb" ]; then + wrapProgram "$out/bin/mariadb" \ + --add-flags '--socket=''$MYSQL_UNIX_PORT'; + fi + wrapProgram "$out/bin/mysql_install_db" \ --add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --basedir=''$MYSQL_BASEDIR';