Cannot build Swift: ninja error swift_RegexParser-swiftmodule-linux-x86_64 missing

When running utils/build-script --release-debuginfo --skip-early-swift-driver, I got following error:

+ /home/tongjiew/swift-project/build/cmake-linux-x86_64/bin/cmake --build /home/tongjiew/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64 -- -j16 all swift-test-stdlib-linux-x86_64
ninja: error: 'stdlib/public/StringProcessing/swift_RegexParser-swiftmodule-linux-x86_64', needed by 'stdlib/public/StringProcessing/LINUX/x86_64/_StringProcessing.o', missing and no known rule to make it
--- Building cmark ---
Building the standard library for: swift-test-stdlib-linux-x86_64
ERROR: command terminated with a non-zero exit status 1, aborting

I could build Swift last week, but I got this error when I tried to run the build script yesterday. I can't figure out the problem, so I made this post according to the get started page.

Here is the GitHub Gist link for full output and hashes: Swift Build Error · GitHub. I am working on Ubuntu 20.04 LTS via WSL2. I did rm -rf ../build before running the utils/build-script. Does anyone know what the issue is? Thanks for the help in advance.

Did you run utils/update-checkout to make sure both swift and swift-experimental-string-processing are up to date?

Yes, I ran utils/update-checkout, followed by rm -rf ../build, and then finally utils/build-script --release-debuginfo --skip-early-swift-driver.

Maybe you can cd into the swift-experimental-string-processing directory and manually update it via git pull. From the error message it looks like your swift-experimental-string-processing repo is not up to date.

When I run git pull in the swift-experimental-string-processing directory, it says I'm not on a branch. I also try running git status and it says

HEAD detached at dev/8
nothing to commit, working tree clean

Maybe something (or maybe myself) accidentally messed up my local git repositories. I just cloned the Swift into a new directory, and the git status of swift-experimental-string-processing directory (in the newly cloned swift project) says

On branch swift/main
Your branch is up to date with 'origin/swift/main'.

nothing to commit, working tree clean

I will try building with this new clone.

1 Like

Maybe you could try update-checkout --clone, it did work for me :)

1 Like

Yeah, that happens sometimes and I'm not sure why. Switching to swift/main and pulling should fix it.

1 Like

I solved the issue by re-cloning the project, ensuring the branch was correct. For people in the future having this issue, it's worth trying the solutions provided by @rxwei and @LucianoPAlmeida first.

I recall that I interrupted the execution of utils/update-checkout because I forgot to set up the ssh-agent. Not sure if these are related.