Skip to content

"File exists" error with zig when ar symlink is broken #1369

@konstin

Description

@konstin

Bug Description

maturin fails to set the ~.cache/cargo-zigbuild/0.14.2/ar symlink with it is already set to another installation of maturin

$ maturin build --release --strip --zig
🍹 Building a mixed python/rust project
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.7
🐍 Not using a specific python interpreter
📡 Using build options features from pyproject.toml
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: File exists (os error 17)

From strace:

stat("/home/konsti/.cache/cargo-zigbuild/0.14.2/ar", 0x7ffd7214fb60) = -1 ENOENT (No such file or directory)
symlink("/home/konsti/pep440/.venv/bin/maturin", "/home/konsti/.cache/cargo-zigbuild/0.14.2/ar") = -1 EEXIST (File exists)

/home/konsti/.cache/cargo-zigbuild/0.14.2/ar exists, but points to a file that has been deleted. I believe the problem is that first check determines whether the file behind the symlink exists (it's doesn't) as opposed to whether the symlink itself exists, and creating the symlink only works if the symlink itself is missing.

Operating System

Ubuntu 20.04

Your maturin version (maturin --version)

0.14.7

Your Python version (python -V)

3.8.10

Your pip version (pip -V)

22.3.1

What bindings you're using

pyo3

Does cargo build work?

  • Yes, it works

If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?

  • Yes
  • Not on windows

Steps to Reproduce

  1. pip install maturin in one venv
  2. maturin build --release --strip --zig in that project
  3. Delete the project
  4. pip install maturin again in another project
  5. maturin build --release --strip --zig again, observer the failure shown above

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions