Closed aravasio closed 7 months ago
At this time, the recommended way to build the toolbox is the same way the CI does, by just executing swift build -c release
.
That being said, the problem is that Arch Linux is not currently supported as a host platform by Swift itself. This is not an issue with Vapor. As far as Linux goes, Swift currently officially supports Ubuntu (18.04 Bionic, 20.04 Focal, and 22.04 Jammy), CentOS 7, Amazon Linux 2, and RedHat UBI 9 (see https://www.swift.org/platform-support/ and https://www.swift.org/download/ for more details). Arch Linux, being a BSD-based distribution, is nominally supported by the compiler itself, but there are clearly issues in various packages, in this case swift-log
. (This being said, I'll see if I can't get that particular failure fixed upstream, since there's no reason not to.)
For the record, the following patch fixes the swift-log
build on Arch Linux (tested on Arch Linux 20231112.0.191179 (Docker tag archlinux:latest
) using the swift-bin
AUR package version 5.9.1-2):
diff --git a/Sources/Logging/Logging.swift b/Sources/Logging/Logging.swift
index 5910e73..23ef1ab 100644
--- a/Sources/Logging/Logging.swift
+++ b/Sources/Logging/Logging.swift
@@ -1388,7 +1388,9 @@ public struct StreamLogHandler: LogHandler {
_ = strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", &localTime)
#else
var timestamp = time(nil)
- let localTime = localtime(×tamp)
+ guard let localTime = localtime(×tamp) else {
+ return "<unknown>"
+ }
strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", localTime)
#endif
return buffer.withUnsafeBufferPointer {
I have opened a PR against the upstream swift-log
repository with this fix, since it also fixes a potential NULL
pointer dereference.
Describe the bug
When cloning toolbox, and running make install, I get the following error:
As one would expect from the reported error, if you go to the Logging.swift file, line 1392 (
timestamp()
function), and add an if let clause, you can build normally.To Reproduce
Simply follow the steps from the Vapor guide on linux. The last part is cloning toolbox and running
make install
. There. That's where it fails.Expected behavior
Toolbox builds and one is able to use cli commands such as
vapor -h
.Environment
Note; I wasn't too specific in my computer specs since I consider this issue to be very straight forward in itself.
However, if needed, I can still provide them. just let me know.