diff --git a/cachi2/core/package_managers/yarn_classic/main.py b/cachi2/core/package_managers/yarn_classic/main.py index 4b6c160f4..20a6fa3c0 100644 --- a/cachi2/core/package_managers/yarn_classic/main.py +++ b/cachi2/core/package_managers/yarn_classic/main.py @@ -218,7 +218,12 @@ def _verify_no_offline_mirror_collisions(packages: Iterable[YarnClassicPackage]) c = Counter(tarballs) duplicate_tarballs = [f"{name} ({count}x)" for name, count in c.most_common() if count > 1] if len(duplicate_tarballs) > 0: - raise PackageManagerError(f"Duplicate tarballs detected: {', '.join(duplicate_tarballs)}") + log.warning( + "Duplicate tarballs detected in the offline mirror: %s. " + "This may lead to unexpected behavior or conflicts during package installation. " + "Ensure that each package has a unique tarball name.", + ", ".join(duplicate_tarballs), + ) # References diff --git a/tests/unit/package_managers/yarn_classic/test_main.py b/tests/unit/package_managers/yarn_classic/test_main.py index cefdc0799..28eea57cd 100644 --- a/tests/unit/package_managers/yarn_classic/test_main.py +++ b/tests/unit/package_managers/yarn_classic/test_main.py @@ -247,7 +247,9 @@ def test_verify_corepack_yarn_version_invalid_version( _verify_corepack_yarn_version(RootedPath(tmp_path), env={"foo": "bar"}) -def test_verify_offline_mirror_collisions_registry_packages() -> None: +def test_verify_offline_mirror_collisions_registry_packages( + caplog: pytest.LogCaptureFixture, +) -> None: packages: Iterable[YarnClassicPackage] = [ RegistryPackage( name="foo", @@ -261,11 +263,13 @@ def test_verify_offline_mirror_collisions_registry_packages() -> None: ), ] - with pytest.raises(PackageManagerError): - _verify_no_offline_mirror_collisions(packages) + _verify_no_offline_mirror_collisions(packages) + assert "Duplicate tarballs detected in the offline mirror: same-1.0.0.tgz (2x)" in caplog.text -def test_verify_offline_mirror_collisions_scoped_registry_packages() -> None: +def test_verify_offline_mirror_collisions_scoped_registry_packages( + caplog: pytest.LogCaptureFixture, +) -> None: packages: Iterable[YarnClassicPackage] = [ RegistryPackage( name="foo", @@ -279,15 +283,21 @@ def test_verify_offline_mirror_collisions_scoped_registry_packages() -> None: ), ] - with pytest.raises(PackageManagerError): - _verify_no_offline_mirror_collisions(packages) + _verify_no_offline_mirror_collisions(packages) + assert ( + "Duplicate tarballs detected in the offline mirror: @colors-colors-1.6.0.tgz (2x)" + in caplog.text + ) -def test_verify_offline_mirror_collisions_git_packages() -> None: +def test_verify_offline_mirror_collisions_git_packages(caplog: pytest.LogCaptureFixture) -> None: packages: Iterable[YarnClassicPackage] = [ GitPackage(name="foo", version="1.0.0", url="https://github.com/user/repo.git#commit-hash"), GitPackage(name="bar", version="1.0.0", url="https://github.com/user/repo.git#commit-hash"), ] - with pytest.raises(PackageManagerError): - _verify_no_offline_mirror_collisions(packages) + _verify_no_offline_mirror_collisions(packages) + assert ( + "Duplicate tarballs detected in the offline mirror: repo.git-commit-hash (2x)" + in caplog.text + )