fallback from realpath to getcwd on failure