As the closest transiting hot Jupiter to Earth, HD 189733b has been the benchmark planet for atmospheric characterization 1,2,3. It has also been the anchor point for much of our theoretical understanding of exoplanet atmospheres from composition 4, chemistry 5,6, aerosols 7 to atmospheric dynamics 8, escape 9 and modeling techniques 10,11. Prior studies of HD 189733b have detected carbon and oxygen-bearing molecules H2O and CO 12,13 in the atmosphere. The presence of CO2 and CH4 has been claimed 14,15 but later disputed 12,16,17. The inferred metallicity based on these measurements, a key parameter in tracing planet formation locations 18, varies from depletion 19,20 to enhancement 21,22, hindered by limited wavelength coverage and precision of the observations. Here we report detections of H2O (13.4 sigma), CO2 (11.2 sigma), CO (5 sigma), and H2S (4.5 sigma) in the transmission spectrum (2.4-5 micron) of HD 189733b. With an equilibrium temperature of ~ 1200K, H2O, CO, and H2S are the main reservoirs for oxygen, carbon, and sulfur. Based on the measured abundances of these three major volatile elements, we infer an atmospheric metallicity of 3-5 times stellar. The upper limit on the methane abundance at 5 sigma is 0.1 ppm which indicates a low carbon-to-oxygen ratio (<0.2), suggesting formation through the accretion of water-rich icy planetesimals. The low oxygen-to-sulfur and carbon-to-sulfur ratios also support the planetesimal accretion formation pathway 23.