getcwd occasionally fail on OSX, try to work around by tracking user.dir