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

Fix FileExistsError on subsequent bazel builds on Windows #1326

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

NovaSagittarii
Copy link
Contributor

Fixes #1181. os.rename() has different behaviors on Windows vs Linux, using os.replace() instead fixes the
issue when a new build is created when previous files exist from an older build.

I'm not sure if this is the best way to do this though since there's the method move_with_overwrite() in emsdk.py which does what os.replace() is supposed to do. Regarding atomicity, according to python documentation, os.replace()'s renaming is atomic as a POSIX requirement, but Windows isn't fully POSIX compliant.

emsdk/emsdk.py

Lines 547 to 553 in 8822664

# On windows, rename/move will fail if the destination exists, and there is no
# race-free way to do it. This method removes the destination if it exists, so
# the move always works
def move_with_overwrite(src, dest):
if os.path.exists(dest):
os.remove(dest)
os.rename(src, dest)

Copy link
Collaborator

@walkingeyerobot walkingeyerobot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks very much!

@walkingeyerobot walkingeyerobot merged commit 9347bc3 into emscripten-core:main Dec 27, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUILD FAILURE] Bazel builds are always failing! emsdk (3.1.31)
2 participants