fix: replace try! with try for createDirectory in SystemStart#1803
Closed
kapil971390 wants to merge 1 commit into
Closed
fix: replace try! with try for createDirectory in SystemStart#1803kapil971390 wants to merge 1 commit into
kapil971390 wants to merge 1 commit into
Conversation
Author
FileManager.createDirectory can fail when the app-root is not writable (e.g. wrong permissions, read-only filesystem). run() is already async throws and every other call in the function propagates errors with plain try — this one line was the exception. Fixes apple#1802
d688367 to
8d0d7f6
Compare
Contributor
|
Hi @kapil971390, thank you for the fix! We've already merged an earlier PR for this: #1785. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #1802.
run()inSystemStart.swiftisasync throws, and every other filesystem and configuration call in it propagates errors with plaintry. Line 107 was the exception — atry!onFileManager.default.createDirectorythat crashes with a fatal error if the app-root directory isn't writable, instead of surfacing a clean error message.Before:
exit code 133 (abort)
After:
exit code 1
One character change:
try!→try.Reproduce:
Tested on macOS 26.5.1, Swift 6.2.4, commit
1d70dd6.