Require 'rails_env' task only when needed

Backport of 4b8b8c1b4d1b516a9ebf8e19d5a14956c5654ac8