ABSTRACT We delved into the assembly pathways and environments of compact groups (CGs) of galaxies using mock catalogues generated from semi-analytical models (SAMs) on the Millennium simulation. We investigate the ability of SAMs to replicate the observed CG environments and whether CGs with different assembly histories tend to inhabit specific cosmic environments. We also analyse whether the environment or the assembly history is more important in tailoring CG properties. We find that about half of the CGs in SAMs are non-embedded systems, 40 per cent are inhabiting loose groups or nodes of filaments, while the rest distribute evenly in filaments and voids, in agreement with observations. We observe that early-assembled CGs preferentially inhabit large galaxy systems ($\sim 60~{{\ \rm per\ cent}}$), while around 30 per cent remain non-embedded. Conversely, lately formed CGs exhibit the opposite trend. We also obtain that lately formed CGs have lower velocity dispersions and larger crossing times than early-formed CGs, but mainly because they are preferentially non-embedded. Those lately formed CGs that inhabit large systems do not show the same features. Therefore, the environment plays a strong role in these properties for lately formed CGs. Early-formed CGs are more evolved, displaying larger velocity dispersions, shorter crossing times, and more dominant first-ranked galaxies, regardless of the environment. Finally, the difference in brightness between the two brightest members of CGs is dependent only on the assembly history and not on the environment. CGs residing in diverse environments have undergone varied assembly processes, making them suitable for studying their evolution and the interplay of nature and nurture on their traits.