rules_jvm_external icon indicating copy to clipboard operation
rules_jvm_external copied to clipboard

Depending on both POM and JAR of the same maven artifact causes symlink error at artifacts pinning

Open cerisier opened this issue 4 months ago • 0 comments

Description

After updating to 6.4, when trying to pin artifacts, bazel reported the following error:

ERROR: An error occurred during the fetch of repository 'rules_jvm_external~~maven~unpinned_maven':
   Traceback (most recent call last):
	File "external/rules_jvm_external~/private/rules/coursier.bzl", line 1077, column 84, in _coursier_fetch_impl
		artifact.update({"file": _relativize_and_symlink_file_in_coursier_cache(repository_ctx, artifact["file"], coursier_cache_path)})
	File "external/rules_jvm_external~/private/rules/coursier.bzl", line 231, column 31, in _relativize_and_symlink_file_in_coursier_cache
		repository_ctx.symlink(absolute_path, repository_ctx.path(artifact_relative_path))
Error in symlink: java.io.IOException: Could not create symlink <skipped> (File exists)

After investigation, I found that 2 of my dependencies were transitively depending on the same maven artifact, one with explicit jar packaging and one without (default to pom), specifically:

  • org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3
  • org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:1.7.3 (note the :jar)

And the introduction of 8388befc8504ac9df779fad8940ec4a112e16fe0, such case will cause a duplicate entry in the dep_tree since both entries for the pom and the jar coordinates of the same artifact will both have their file point the the same .jar.

https://github.com/bazel-contrib/rules_jvm_external/blob/8388befc8504ac9df779fad8940ec4a112e16fe0/private/rules/coursier.bzl#L955-L958

cerisier avatar Oct 12 '24 10:10 cerisier