automatic environment discovery without using subprocesses