fix: replace try! with try for createDirectory in SystemStart
Fixes #1802.
run() in SystemStart.swift is async throws, and every other filesystem and configuration call in it propagates errors with plain try. Line 107 was the exception — a try! on FileManager.default.createDirectory that crashes with a fatal error if the app-root directory isn't writable, instead of surfacing a clean error message.
Before:
ContainerCommands/SystemStart.swift:107: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "apiserver" in the folder "test-approot"." ...
exit code 133 (abort)
After:
Error: You don't have permission to save the file "apiserver" in the folder "test-approot".
exit code 1
One character change: try! → try.
Reproduce:
rm -rf test-data && make APP_ROOT=test-data all
mkdir -p /tmp/test-approot && chmod 555 /tmp/test-approot
bin/container system start --app-root /tmp/test-approot
Tested on macOS 26.5.1, Swift 6.2.4, commit 1d70dd6.
Crash output from reproduce run (before fix):
ContainerCommands/SystemStart.swift:107: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "apiserver" in the folder "test-approot"." UserInfo={NSFilePath=/tmp/test-approot/apiserver, NSURL=file:///tmp/test-approot/apiserver, NSUnderlyingError=0x10836cbc0 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}}
After fix:
Error: You don't have permission to save the file "apiserver" in the folder "test-approot".
exit code 1, no crash.
Hi @kapil971390, thank you for the fix! We've already merged an earlier PR for this: #1785.