Skip to content

Swiftly-Use: JSON: Handle no selected toolchain#546

Merged
cmcgee1024 merged 1 commit into
swiftlang:mainfrom
etcwilde:ewilde/545-swiftly-use-no-selected-toolchain-json
May 28, 2026
Merged

Swiftly-Use: JSON: Handle no selected toolchain#546
cmcgee1024 merged 1 commit into
swiftlang:mainfrom
etcwilde:ewilde/545-swiftly-use-no-selected-toolchain-json

Conversation

@etcwilde
Copy link
Copy Markdown
Member

Uninstalling all of the tools in Swiftly and printing the current toolchain with swiftly use --format=json results in swiftly printing nothing. This is invalid JSON, so tools like the VSCode extension would emit an error.

Without the fix, the empty JSON passed to the Foundation JSON decoder emits the following error:

Caught error: Error Domain=NSCocoaErrorDomain Code=3840 "Unable to parse empty data." UserInfo={NSDebugDescription=Unable to parse empty data.}

fixes: #545

Uninstalling all of the tools in Swiftly and printing the current
toolchain with `swiftly use --format=json` results in swiftly printing
nothing. This is invalid JSON, so tools like the VSCode extension would
emit an error.

Without the fix, the empty JSON passed to the Foundation JSON decoder
emits the following error:

```
Caught error: Error Domain=NSCocoaErrorDomain Code=3840 "Unable to parse empty data." UserInfo={NSDebugDescription=Unable to parse empty data.}
```

Fixes: swiftlang#545
@cmcgee1024 cmcgee1024 merged commit e00c1f5 into swiftlang:main May 28, 2026
25 checks passed
@etcwilde etcwilde deleted the ewilde/545-swiftly-use-no-selected-toolchain-json branch May 28, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid JSON emitted from swiftly use --format=json with no installed or selected toolchains

3 participants