Group Group Group Group Group Group Group Group Group

"swift build -c release" isn't generating an executable

Hey guys, I’m having a strange problem. I am trying to upgrade my Vapor project by running ‘swift build -c release’ on my Ubuntu server and I’m not getting a ‘release’ symlink in the build folder or a ‘Run’ executable in the final build.

This has worked before and the server is currently running a version that I built just a few days ago. When I updated then I was able to build, but it took a few clean/build cycles before the ‘.build/release/Run’ executable appeared.

Does anyone have an idea of what might be causing this issue? Do I need to stop the currently running application in order to build the new version?

I found the solution!

Summary:

  • I added a library that included CommonCrypto which isn’t available in Linux (I guess it’s not so common after all)
  • Removing that library and replacing with swift-crypto does the trick.

Ways to avoid this issue:

  • Copy the .build/release folder to a safe location and save as ‘1.0’ or whatever your version number is.
  • Pull your changes to the server from git, then run swift package clean to clear out your build folder
  • Run swift build -c release once to build the project. (Errors should show up in this step)
  • Run swift build -c release again to finish the linking steps which creates the .build/release symlink. (This is a 4 step build)
  • Verify symlink exists, then restart server.

Those steps assume you are using Supervisor or a Cronjob (run-one) to keep your Vapor server running. This also allows you to revert to your previous working build if you can’t build your updates and you don’t see any errors.

I found this interesting. Thanks for posting your fix!

For future reference (because you’re probably going to hit this issue again) - the Swift compiler requires a lot of memory to work. When it runs out of memory it has a habit of just dying with no message which is what you hit here. The way around this is to enable swap which should fix your issues

oh my god, thanks guy