As I discuss in this question, in the Bala Kanda of Ramayana, Vishwamitra tells Rama and Lakshmana the famous story of the descent of the Ganga river to the Earth. As described in this chapter of the Bala Kanda, Rama's ancestor Sagara once conducted an Ashwamedha Yagna (horse ritual), and Indra, fearing that the yagna would make Sagara too powerful, stole the sacrificial horse so that Sagara couldn't complete the ritual. So Sagara sent his sons to look for the horse, and they scoured the earth trying to find it. As described in the next chapter, Sagara's sons finally found the horse near the ashram of the sage Kapila:
But all those great-souled and great-mighty ones with terrible dash have seen the Infinite Vasudeva in the form of sage Kapila there in the northeast, and oh, descendant of Raghu, they have also seen the ritual-horse moving nearby that sage Kapila, thus all of the sons of Sagara obtained a matchless delight.... 'You the malicious one, you have indeed stolen our ritual-horse, and in fact, you should know that we who arrived here are the sons of Sagara.' Thus Sagara's sons shouted at sage Kapila.... Oh, Rama of Kakutstha, then that great-souled sage Kapila, rather Vishnu with unimaginable power, has rendered all of those sons of Sagara as heaps of ashes by virtue of his 'hum' sound.
It was the quest to scatter the ashes of Sagara's sons in a holy body of water that motivated Sagara's descendant Bhagiratha's famous quest to bring the river Ganga from Devaloka to Earth.
But my question is about this passage's reference to the sage Kapila. For those who don't know, Kapila was an ancient incarnation of Vishnu, born to Brahma's son Kardama and Swayambhuva Manu's daughter Devahuti. He was the founder of the Sankhya school, one of the six Astika or orthodox schools of Hindu philosophy, according to which the universe consists of Purushas or conscious beings interacting with Prakriti or unconscious matter. The Bhagavad Gita is based in large part on a theistic version of Kapila's Sankhya philosophy.
In any case, my question is, is the Ramayana the earliest Hindu scripture which refers to Kapila? There are plenty of references to Kapila after the Ramayana; this chapter and the subsequent chapters of the Srimad Bhagavatam describe the birth of Kapila and how he taught his mother Devahuti. But are there any references to Kapila before the Ramayana? Do the Vedas or Upanishads mention him?