(PUP-3389) Do not list all directories when getting an environment

Cherry pick that had one conflict in environments.rb when picked into stable - please review.