fix KeyError in os.environ check