Menu

Cleaning up SwiftPM's leftover lock files without breaking a running build
📰

Cleaning up SwiftPM's leftover lock files without breaking a running build

DEV Community: ios·Darkø Tasevski·about 17 hours ago
#EU8CfBNC
#devtoios#devto#dev#lock#file
Long article (2234 words) — no AI summary yet.
Reading 0:00
15s threshold

My build scripts point TMPDIR at one scratch directory that every build and test run on the machine shares, and a small reaper cleans up whatever Xcode, SwiftPM and the scripts leave in it once it's a few days old. It was told never to touch SwiftPM's lock files, which are zero-byte files with names like _Users_me_Code_project_.build.lock , and by the time I looked there were 621 of them. They take no space, but there's one for every path SwiftPM ever locked, nothing ever removes them, and they clutter every listing of the directory, so this post is about which of them we can delete without pulling a lock out from under a build that holds it, and about the signals that look like they'd tell us that and don't.

What SwiftPM does with these files

SwiftPM's FileLock (in swift-tools-support-core, Sources/TSCBasic/Lock.swift ) opens <TMPDIR>/<name> with O_CREAT and takes a flock on it, exclusive by default.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.