Ensure the projects directory is valid before using it.

See #304.