Skip to content

pipstar regression: Could not rename ... : already existsΒ #3500

@thirtyseven

Description

@thirtyseven

🐞 bug report

Affected Rule

The issue is caused by the rule: pip.parse

Is this a regression?

Yes, the previous version in which this bug was not present was: 1.7.0

Description

Some pip packages fail to build in 1.8.0-rc1 with errors like:

ERROR: no such package '@@rules_python++pip+pypi_310_libclang//': java.io.IOException: Could not rename /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_libclang/site-packages/libclang-18.1.1.data/platlib to /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_libclang/site-packages: already exists

πŸ”¬ Minimal Reproduction

MODULE.bazel:

bazel_dep(name = "rules_python", version = "1.8.0-rc1")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    python_version = "3.10",
)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
    hub_name = "pypi",
    python_version = "3.10",
    requirements_by_platform = {
        "//:requirements_linux.txt": "linux_*",
        "//:requirements_mac.txt": "osx_*",
    },
)
use_repo(pip, "pypi")

uv = use_extension(
    "@rules_python//python/uv:uv.bzl",
    "uv",
    dev_dependency = True,
)

BUILD.bazel:

load("@rules_python//python/uv:lock.bzl", "lock")

DEFAULT_UV_ARGS = [
    "--index-strategy=unsafe-best-match",
]

# Generate lock files for default Python version
lock(
    name = "requirements_mac",
    srcs = [":requirements.in"],
    out = "requirements_mac.txt",
    args = DEFAULT_UV_ARGS + ["--python-platform=macos"],
)

lock(
    name = "requirements_linux",
    srcs = [":requirements.in"],
    out = "requirements_linux.txt",
    args = DEFAULT_UV_ARGS + ["--python-platform=linux"],
)

requirements.in:

tensorflow==2.18.0

Run:

bazel run :requirements_mac.update
bazel run :requirements_linux.update
bazel build @pypi//...

πŸ”₯ Exception or Error




bazel build @pypi//...     
INFO: Repository rules_python++pip+pypi_310_libclang instantiated at:
  : in 
Repository rule whl_library defined at:
  /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python+/python/private/pypi/whl_library.bzl:730:30: in 
ERROR: /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python+/python/private/pypi/whl_library.bzl:304:28: An error occurred during the fetch of repository 'rules_python++pip+pypi_310_libclang':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python+/python/private/pypi/whl_library.bzl", line 451, column 26, in _whl_library_impl
		_extract_whl_star(rctx, whl_path = whl_path, logger = logger)
	File "/private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python+/python/private/pypi/whl_library.bzl", line 304, column 28, in _extract_whl_star
		rctx.rename(src, dest)
Error in rename: java.io.IOException: Could not rename /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_libclang/site-packages/libclang-18.1.1.data/platlib to /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_libclang/site-packages: already exists
ERROR: no such package '@@rules_python++pip+pypi_310_libclang//': java.io.IOException: Could not rename /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_libclang/site-packages/libclang-18.1.1.data/platlib to /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_libclang/site-packages: already exists
ERROR: /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi/libclang/BUILD.bazel:5:12: @@rules_python++pip+pypi//libclang:dist_info depends on @@rules_python++pip+pypi_310_libclang//:dist_info in repository @@rules_python++pip+pypi_310_libclang which failed to fetch. no such package '@@rules_python++pip+pypi_310_libclang//': java.io.IOException: Could not rename /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_libclang/site-packages/libclang-18.1.1.data/platlib to /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_libclang/site-packages: already exists
Use --verbose_failures to see the command lines of failed build steps.
ERROR: Analysis of target '@@rules_python++pip+pypi//libclang:dist_info' failed; build aborted: Analysis failed

🌍 Your Environment

Operating System:

  
Mac OS 15.7.3
  

Output of bazel version:

  
8.5.0
  

Rules_python version:

  
1.8.0-rc1
  

Anything else relevant?

This issue doesn't occur when using --repo_env=RULES_PYTHON_ENABLE_PIPSTAR=0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions