expand basedir before usage

since later on we do take care of expanding user, do it earlier to  make sure things work