Running Django tests in parallel on MariaDB, get "No such file or directory: 'mysqldump'"
I have a Django project running locally, with its database as MariaDB 10.6 running in a Docker container. The Django tests work fine, but when I try to run them with a --parallel
flag I get an error "FileNotFoundError: [Errno 2] No such file or directory: 'mysqldump'".
The docker-compose.yml
is:
services:
db:
container_name: my_db
env_file: .env
image: mariadb:10.6.17
ports:
- 5556:3306
restart: unless-stopped
volumes:
- ./docker/db/init:/docker-entrypoint-initdb.d
- mysql_data:/var/lib/mysql
volumes:
mysql_data:
And here's the traceback after running manage.py test --parallel
:
Using shuffle seed: 2678352772 (generated)
Found 965 test(s).
Creating test database for alias 'default'...
Cloning test database for alias 'default'...
Traceback (most recent call last):
File "manage.py", line 26, in <module>
main()
File "manage.py", line 22, in main
execute_from_command_line(sys.argv)
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/core/management/commands/test.py", line 24, in run_from_argv
super().run_from_argv(argv)
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/core/management/commands/test.py", line 68, in handle
failures = test_runner.run_tests(test_labels)
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/test/runner.py", line 1054, in run_tests
old_config = self.setup_databases(
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/test/runner.py", line 950, in setup_databases
return _setup_databases(
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/test/utils.py", line 230, in setup_databases
connection.creation.clone_test_db(
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/db/backends/base/creation.py", line 256, in clone_test_db
self._clone_test_db(suffix, verbosity, keepdb)
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/db/backends/mysql/creation.py", line 60, in _clone_test_db
self._clone_db(source_database_name, target_database_name)
File "/Users/phil/Projects/MyProject/Django/my-project/.venv/lib/python3.8/site-packages/django/db/backends/mysql/creation.py", line 77, in _clone_db
with subprocess.Popen(
File "/Users/phil/.local/share/uv/python/cpython-3.8.19-macos-aarch64-none/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/phil/.local/share/uv/python/cpython-3.8.19-macos-aarch64-none/lib/python3.8/subprocess.py", line 1720, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'mysqldump'
As shown by
with subprocess.Popen(
and
No such file or directory: 'mysqldump'
You are missing the mysqldump
command on your Mac (Based off the file paths), which you will be able to install via brew install mysql-client
or brew install mysql
if you want the server installed as well.