Expand environment variable before checking the existence of the directory.