  Aims: The large abundances of CH$^+$ in the diffuse interstellar medium (ISM)
are a long standing issue of our understanding of the thermodynamical and
chemical states of the gas. We investigate, here, the formation of CH+ in
turbulent and multiphase environments, where the heating of the gas is almost
solely driven by the photoelectric effect. Methods: The diffuse ISM is
simulated using the magnetohydrodynamic (MHD) code RAMSES which
self-consistently computes the dynamical and thermal evolution of the gas along
with the time-dependent evolutions of the abundances of H$^+$, H, and H$_2$.
The rest of the chemistry, including the abundance of CH$^+$, is computed in
post-processing, at equilibrium, under the constraint of out-ofequilibrium of
H$^+$, H, and H$_2$. The comparison with the observations is performed taking
into account an often neglected, yet paramount, piece of information, namely
the length of the intercepted diffuse matter along the observed lines of sight.
Results: The quasi totality of the mass of CH$^+$ originates from the unstable
gas, in environments where the kinetic temperature is larger than 600 K, the
density ranges between 0.6 and 10 cm$^{-3}$, the electronic fraction ranges
between 3 x 10$^{-4}$ and 6 x 10$^{-3}$, and the molecular fraction is smaller
than 0.4. Its formation is driven by warm and out-of-equilibrium H$_2$
initially formed in the cold neutral medium (CNM) and injected in more diffuse
environments and even the warm neutral medium (WNM) through a combination of
advection and thermal instability. The simulation which displays the tightest
agreement with the HI-to-H$_2$ transition and the thermal pressure distribution
observed in the Solar Neighborhood is found to naturally reproduce the observed
abundances of CH$^+$, the dispersion of observations, the probability of
occurrence of most of the lines of sight, the fraction of non-detections of
CH$^+$, and the distribution of its line profiles. The amount of CH$^+$ and the
statistical properties of the simulated lines of sight are set by the fraction
of unstable gas rich in H$_2$ which is controlled, on Galactic scales, by the
mean density of the diffuse ISM (or, equivalently, its total mass), the
amplitude of the mean UV radiation field, and the strength of the turbulent
forcing. Conclusions: This work offers a new and natural solution to an 80
years old chemical riddle. The almost ubiquitous presence of CH$^+$ in the
diffuse ISM likely results from the exchanges of matter between the CNM and the
WNM induced by the combination of turbulent advection and thermal instability,
without the need to invoke ambipolar diffusion or regions of intermittent
turbulent dissipation. Through two phase turbulent mixing, CH$^+$ might thus be
a tracer of the H$_2$ mass loss rate of CNM clouds.
