Drush and rsync
Both drush and rsync are handy tools to automate the deployment of Drupal sites. You just have to be careful how you combine them.
In my development environment I have a local CVS checkout of drush and I use rsync to push that directory to the remote production server. This way I'm sure both development and production use the same version of drush without the need to install a CVS client on the production server.
Unfortunately my initial attempts to get drush running on the remote system always resulted in the following error message:
The command 'drush.php help' could not be found.
Initially I assumed there was something wrong with the path to the drush executable or the code that detects the location of the drush.php file but only after a while I found the real culprit.
To reduce the number of files that need to be synced I used rsync's --cvs-exclude option. This option makes rsync ignore certain files and directories in the same way CVS does. For example it will filter out all CVS directories. It turns out that a lot more files get excluded:
RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS .make.state .nse_depinfo *~ #* .#* ,* _$* *$ *.old *.bak *.BAK *.orig *.rej .del-* *.a *.olb *.o *.obj *.so *.exe *.Z *.elc *.ln core .svn/ .git/ .bzr/
Notice core in that list? Guess in which directory drush keeps major parts of its code! By using the --cvs-exclude option of rsync, my remote drush directory was missing approximately 2500 lines of PHP code resulting in the bizarre error message.
The solution is to stop using the --cvs-exclude option or use the --filter option to tune the list of files to exclude during syncing.