Skip to content

Swiftly installed with Homebrew freezes VS Code Swift plugin #454

@SimplyDanny

Description

@SimplyDanny

Swiftly installed with Homebrew doesn't link its binary into SWIFTLY_BIN_DIR. If we just call swiftly from the command line, it refers to $(brew --prefix)/bin/swiftly which is actually a symlink to $(brew --prefix)/Cellar/swiftly/1.1.0/bin/swiftly.

The check validateLinked(ctx), which is called first in almost all Swiftly commands, is happy if swiftly is either a symlink or exists in SWIFTLY_BIN_DIR. So just calling swiftly from the command-line is usually fine.

However, the combination of Swiftly (1.1.0) and the Swift extension for VS Code is currently problematic, in that VS Code is more or less blocked. Basic interactions don't work anymore, because it's busy with "Activating Swift for Visual Studio Code ...". The reason is an endless loop caused by the following circumstances:

Internally, the extension first checks where swift is and finds it at SWIFTLY_BIN_DIR/swift. It then resolves this symbolic link directly to the final real path $(brew --prefix)/Cellar/swiftly/1.1.0/bin/swiftly. Since this is not a symlink, validateLinked(ctx) requires it to effectively live in SWIFTLY_BIN_DIR. This is clearly not the case.

The result is the message "Swiftly is currently unlinked ..." being reported. The VS Code extension interprets it as a path and tries to traverse all its parents which never comes to an end (since this is not a path at all).

I was about to fix this, but got unsure on what the right fix would actually be. I think, it's something Swiftly needs to handle correctly. The question is how to recognize when it's okay that swiftly does not live in SWIFTLY_BIN_DIR. Only excluding symlinks is obviously not enough. Should absolute paths starting with brew --prefix be accepted as well? Absolute paths in general? Why is it so important to run validateLinked(ctx) every time in the first place?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions