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

Build fails on Windows when cxx.h is already present in the targets folder due to cache #1085

Closed
aminya opened this issue Aug 27, 2022 · 4 comments · Fixed by #1087
Closed

Comments

@aminya
Copy link

aminya commented Aug 27, 2022

On Windows, the build fails when a project is built with a cache and cxx.h is already present. It fails to copy cxx.h.

https://github.com/SunDoge/simdjson-rust/runs/8049220520?check_suite_focus=true#step:6:71

error: failed to run custom build command for `simdjson-rust v0.2.0-alpha (D:\a\simdjson-rust\simdjson-rust)`

Caused by:
  process didn't exit successfully: `D:\a\simdjson-rust\simdjson-rust\target\debug\build\simdjson-rust-d635beff2633e3ed\build-script-build` (exit code: 1)
  --- stderr


  cxxbridge error: Failed to copy `C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\cxx-1.0.73\include\cxx.h` -> `D:\a\simdjson-rust\simdjson-rust\target\debug\build\simdjson-rust-457ffe0621787f66\out\cxxbridge\include\rust\cxx.h`

  Caused by:
      The filename, directory name, or volume label syntax is incorrect. (os error 123)

SunDoge/simdjson-rust#16

@dtolnay
Copy link
Owner

dtolnay commented Aug 30, 2022

Sigh — apparently std::fs::copy on Windows cannot copy between two different drive letters? What a strange error message from the OS in that case. I don't have access to Windows but I am able to reproduce this issue in GitHub Actions.

I tried adding some logging to look at whether the paths involved exists. The path we are copying from does exist, as expected. The path we are copying to does not exist, as expected. The parent directory of the path to does exist, and is a directory, as expected.

from = "C:\\Users\\runneradmin\\.cargo\\git\\checkouts\\cxx-be839b8f5bc98a2b\\1b1f78a\\include\\cxx.h"
from.exists() = true
to = "D:\\a\\simdjson-rust\\simdjson-rust\\target\\debug\\build\\simdjson-rust-73b1080797fedd25\\out\\cxxbridge\\include\\rust\\cxx.h"
to.exists() = false
parent = "D:\\a\\simdjson-rust\\simdjson-rust\\target\\debug\\build\\simdjson-rust-73b1080797fedd25\\out\\cxxbridge\\include\\rust"
parent.exists() = true
parent.is_dir() = true

cxxbridge error: Failed to copy `C:\Users\runneradmin\.cargo\git\checkouts\cxx-be839b8f5bc98a2b\1b1f78a\include\cxx.h` -> `D:\a\simdjson-rust\simdjson-rust\target\debug\build\simdjson-rust-73b1080797fedd25\out\cxxbridge\include\rust\cxx.h`

Caused by:
    The filename, directory name, or volume label syntax is incorrect. (os error 123)

@dtolnay
Copy link
Owner

dtolnay commented Aug 30, 2022

Correction, in the above, the path:
D:\\a\\simdjson-rust\\simdjson-rust\\target\\debug\\build\\simdjson-rust-73b1080797fedd25\\out\\cxxbridge\\include\\rust\\cxx.h
does exist, and is a symlink, where read_link on it reports that it points to:
\\??\\C:\\Users\\runneradmin\\.cargo\\git\\checkouts\\cxx-be839b8f5bc98a2b\\88c2051\\include\\cxx.h
which does not exist, which is why exists() reports false on the link. We are using .exists() incorrectly and should be using something like .symlink_metadata().is_ok().

@dtolnay
Copy link
Owner

dtolnay commented Aug 30, 2022

That fix makes it proceed slightly further but it still doesn't work because cxx-build is unable to get rid of the old dangling symlink, despite now knowing that it exists. On Windows std::fs::remove_file(path) returns "Access is denied" error if path is a symlink whose target no longer exists.

@aminya
Copy link
Author

aminya commented Aug 31, 2022

Thanks for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants