swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
706 stars 47 forks source link

See error message when swift.path is set #843

Open award999 opened 4 weeks ago

award999 commented 4 weeks ago

Describe the bug On windows (UPDATE: also seen on macOS) even when swift.path setting is set and the swift exe exists in that directory, see this error message

Screenshot 2024-06-05 at 1 17 08 PM

Seems to only happen when swift is not in PATH

To Reproduce Steps to reproduce the behavior:

  1. Correctly select your toolchain
  2. Make sure swift is not in PATH
  3. Reload window

Expected behavior If have a valid toolchain selected, shouldn't matter if cannot detect in PATH

Environment

matthewbastien commented 3 weeks ago

Did some testing around this on Windows and I am able to reproduce if I remove the path to the swift runtimes directory. The swift toolchain installer actually adds three separate directories to PATH:

  1. <user-dir>\AppData\Local\Programs\Swift\Runtimes\6.0.0\usr\bin
  2. <user-dir>\AppData\Local\Programs\Swift\Toolchains\6.0.0+Asserts\usr\bin
  3. <user-dir>\AppData\Local\Programs\Swift\Tools\6.0.0

If that first path to the Runtimes directory is malformed or deleted, then swift.exe will fail to launch and cause the extension to be unable to resolve the toolchain version. Unfortunately, this means that selecting a toolchain folder will never work on Windows. I suspect that this will require changes to the toolchain itself to get working.

award999 commented 3 weeks ago

Opened https://github.com/apple/swift-installer-scripts/issues/303 to see if there is anything that can be done with toolchain