fix order of env hook sourcing (fix #297)