Make sure no crash when current directory doesn't exist.
fix #2452