drupal sql-sync @prod @local issue on Mac OSX

Just spent the last three hours trying to figure out why drush sql-sync won't sync the prod with local. It all started after configuring my aliases and trying to clone production database.

Trial #1: The dump started and afterwards I got the error: "The Drush sql-dump command did not report the path to the dump file produced"

This was an easy fix, since I am using the drush master branch from github, I just done a git pull && composer update to bring drush to latest version both on my Mac and remote server

Trial #2: Query failed - a very dry message.

This is was a PITA. The dump was brought locally, but somehow importing into mysql fails. Tried using -d -v switches to debug without success. Got my hands dirty and start digging into drush code to debug it and finally added a debug statement in the command execution code. And to my surprise, the error was that mysql command is not found:

sh: mysql: command not found

I have mysql55 installed via brew and located in /usr/local/bin/mysql, which is also incidentally in $PATH. I really don't understand why the shell spawned (?) by drush does not copy the environment, but after symlinking to /usr/bin, everything seem to work fine.

Phew!