lately i’ve been getting a lot of intermittent VSCode + SPM errors that happen after clearing the .build
directory, such as:
warning: 'swift-syntax': skipping cache due to an error: .build/repositories/swift-syntax-e33d5ec5 already exists unexpectedly
Computed https://github.com/apple/swift-markdown at 0.3.0 (0.34s)
Computing version for https://github.com/apple/swift-nio-http2
error: Dependencies could not be resolved because no versions of 'swift-nio-http2' match the requirement 1.29.0..<1.30.0 and root depends on 'swift-nio-http2' 1.29.0..<1.30.0.
...
error: 'swift-syntax': Error Domain=NSCocoaErrorDomain Code=512 "(null)"
Creating working copy for https://github.com/apple/swift-nio-ssl.git
Working copy of https://github.com/apple/swift-syntax resolved at 509.0.2
...
error: Couldn’t get the list of tags:
fatal: cannot change to '.build/repositories/swift-collections-51f90653': No such file or directory
the errors don’t occur consistently, and retrying swift build
almost always resolves the issue. what could be going on here?
Would you be able to clarify which exact versions of Swift and SwiftPM, and which OS and its exact version were you able to reproduce this with? Is this reproducible outside of VS Code? Which version of the VS Code extension is this reproducible with, if opening your project is a required reproduction step? (FWIW this information is required for any actionable bug report for us to be able to make any conjectures)
i’m using 5.9.2, and i’m using the SPM that ships with the 5.9.2 toolchain. the VSCode extension version is 1.7.2. the toolchain is installed in an Amazon Linux 2 docker container, and i have not used SPM outside the container enough to know if the issue also occurs on the host.
i understand this is not sufficient to begin a real investigation into the actual failure mechanism. it happens seemingly randomly but also frequently enough that i really doubted if i was the only one experiencing this; hence why i made this forums post.
i’ve experienced a few other issues with the reliability of swift on VSCode, such as sourcekit-lsp crashing when renaming files. when i raise these issues, others say that they cannot reproduce the issue and that they have never heard of such a thing happening. which is frustrating because problems with swift on VSCode (especially since 5.9) happen so frequently for me that i have to delete /var/lib/apport/coredump/
every few hours due to no space remaining on the root partition. so i figured the first step to resolving it is to figure out who else is seeing similar issues, and if there are any patterns in the failures.