Chocolate is in trouble. Cacao, the plant used to produce cocoa and other treats, faces a global shortage by 2020, and the crop may be gone as soon as 2050. The implications of this deficit go beyond candy bars: cacao’s extinction spells economic strife for millions of people who depend on its production for their livelihoods.

70% of cacao is grown in four countries: Ivory Coast, Ghana, Nigeria and Cameroon. These countries are expected to experience an increase in temperature of 3.8 degrees Fahrenheit by 2050, a change that is projected to dramatically alter the geography of where the plant can grow. Additionally, floods, droughts and windstorms are already common where cacao is cultivated – and climate change is making these extreme weather events worse and more frequent.

Cacao plants require a rainforest environment with consistent temperature, plentiful rain, and high humidity. Such areas currently only exist in a band roughly 20 degrees north and south of the equator. Because of climate change, the soil where cacao currently thrives may become barren by 2050. Higher elevations could become suitable for cacao production in the future, but the majority of such areas are protected for biodiversity and wildlife habitat.

In addition to threats to their habitat, cacao trees are particularly vulnerable to fungal infections and pests, partly because all varieties of cacao belong to a single species. Different strains of cacao lack the genetic variety to bolster the plants’ resistance to such maladies as witches’ broom, frosty pod rot,  cocoa pod borer and cocoa swollen shoot. Such biological threats to cacao production are emboldened by rising temperatures, which enable pests to survive longer into the winter and further from the equator than ever before.

Thankfully, a diverse array of stakeholders is coming together to address these challenges. In one noteworthy collaboration, the University of California and the Mars Company are teaming up to explore the possibility of using gene-editing technology to create more resilient cacao crops. These high-tech cacao beans will hopefully be better equipped to survive the complex challenges of the future.