Instead of making sure we set global variables and call Unix.putenv in the right order, pass the environment explicitely everywhere.