More than a hundred years. The amount of time we have known about burning carbon is longer than the amount of time, since we began the industrial revolution until we were warned.
co2 warning history, 1800's
https://daily.jstor.org/how-19th-century-scientists-predicted-global-warming/