Sorry, the positioning of my line note was misleading. Let me try putting this another way. Since most Rake/Rails tasks pick up Rails.env from the environment variable "RAILS_ENV", I think this:

export RAILS_ENV=production
bundle exec rake db:migrate VERSION=$VERSION

is equivalent to:

bundle exec rake db:migrate VERSION=$VERSION RAILS_ENV=production

So I don't think there was a need to paste the "RAILS_ENV=$RAILS_ENV" clause into Rake command strings once