Upvote:2

Aprove answer
  before_all do |lane|
    Dotenv.overload '../../.env'
    environment = lane_context[SharedValues::ENVIRONMENT]
    unless environment.nil?
        puts "Load .env file of #{environment}"
        Dotenv.overload '../../.env.' + environment
    end
  end

Credit Goes to: stackoverflow.com

Related question with same questions but different answers