Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 3 tasks
konstin opened this issue Dec 21, 2022 · 2 comments · Fixed by #1375
Closed
2 of 3 tasks

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

konstin opened this issue Dec 21, 2022 · 2 comments · Fixed by #1375
Labels
bug Something isn't working

Comments

@konstin
Copy link
Member

konstin commented Dec 21, 2022

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
@konstin konstin added the bug Something isn't working label Dec 21, 2022
@messense
Copy link
Member

We're using std::path::Path::exists in https://github.com/rust-cross/cargo-zigbuild/blob/0c658ead789e9f63c7b7dc4696b3a48e5486a1c9/src/zig.rs#L750-L752 and the doc says:

This function will traverse symbolic links to query information about the destination file.

If you cannot access the metadata of the file, e.g. because of a permission error or broken symbolic links, this will return false.

So I think it's already checking whether the file behind the symlink exists?

@konstin
Copy link
Member Author

konstin commented Dec 25, 2022

I think this needs to handle three cases:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants