Fix realpath usage for missing files/directories.