businho / django-migrations-ci

Cached migrations on CI (and local) for faster migrations
MIT License
28 stars 7 forks source link

MacOS: migrateci cant find shell command "mysqldump" #56

Closed maj1n167 closed 2 months ago

maj1n167 commented 3 months ago

Hello,

im working on a mac and the project im working on uses "migrateci" to build local test databases, which get dumped/cached to be able to load them later on.

when investigating a bug, i used git bisect to run migrateci over many commits. all of them failed on the end, when "mysqldump" is used inside a shell that is opened from python. since i cant define which shell it is loading, and the "paths" are configured in my user profile, it cant find mysqldump. i even tried adding /usr/local/bin to the /etc/paths file to fix this problem, but it didnt work.

i am not very "skilled" and capable of understanding the problems, but what i see is that the shell opened by migrateci does not have the path to mysqldump.

maybe someone can help me with that issue.

the following error is what i get:

django_migrations_ci.shell.MigrateCIShellException: /bin/sh: mysqldump: command not found

i could fix that problem temporarely:

since mysqldump is part of the mysql package which is installed via brew on my system, root doesnt know the binary "mysqldump".

to fix that, i created a symlink in /usr/local/bin to the mysqldump binary file.

that solved it.

iurisilvio commented 3 months ago

Interesting, I probably want a config path to each command (mysqldump/pg_dump/sqlite), because I can't trust we'll always have them globally available.

I'll try to make it soon.

iurisilvio commented 2 months ago

Ah I see I don't pass PATH to the subprocess, should be enough to follow your system config.

iurisilvio commented 2 months ago

@maj1n167 Any chance you test your case using PR #58? I expect it to work if your PATH is properly configured.

maj1n167 commented 2 months ago

i can test this sure. i will inform you when i did.

iurisilvio commented 2 months ago

If for some reason it doesn't work, you have to add the mysqldump path to PATH env variable. I think this is a better solution than a custom env var.

maj1n167 commented 2 months ago

first i created an environment, where the the error is persistent.

my PATH is already properly configured. since homebrew installs it correctly.

i patched the package as its shown in PR #58

afterwards i restarted migrateci:

image

it worked for me. i would say that PR #58 fixes the issue, thank you !

iurisilvio commented 2 months ago

Thanks for the test! I merged and released v0.10.1 now. 🎉