Skip to content

VSCode sets an invalid developer directory when choosing a toolchain #1528

Closed
@jakepetroules

Description

@jakepetroules

Describe the bug
VSCode sets an invalid developer directory when choosing a toolchain

To Reproduce
Steps to reproduce the behavior:

  1. Select Swift Toolchain
  2. Enter an explicit one, like ~/Library/Developer/Toolchains/swift-6.1-RELEASE.xctoolchain

Expected behavior
Toolchain should work and be usable. Instead, I receive:

The Swift executable at "/Users/jakepetroules/Library/Developer/Toolchains/swift-6.1-RELEASE.xctoolchain/usr/bin" either could not be found or failed to launch. Please select a new toolchain.

Swift extension logs reveal the following:

20:50:22: Activating Swift for Visual Studio Code...
20:50:23: Failed to discover Swift toolchain
20:50:23: Error: Command failed: xcrun --sdk macosx --show-sdk-path
xcrun: error: invalid DEVELOPER_DIR path (/Users/jakepetroules/Library/Developer/Xcode/DerivedData/Xcode-bciqhkcgebcelmdmrkdwpisviqpz/Build/Products/Debug/Xcode.app/Contents/Developer), missing xcrun at: /Users/jakepetroules/Library/Developer/Xcode/DerivedData/Xcode-bciqhkcgebcelmdmrkdwpisviqpz/Build/Products/Debug/Xcode.app/Contents/Developer/usr/bin/xcrun

VSCode is finding that DEVELOPER_DIR via Spotlight and for some reason trying to use it, even though DEVELOPER_DIR isn't set to that value and xcode-select -p also doesn't return that value.

Prior to selecting my Swift toolchain, neither swift.path nor swift.swiftEnvironmentVariables is set. After doing so, it's:

    "swift.path": "/Users/jakepetroules/Library/Developer/Toolchains/swift-6.1-RELEASE.xctoolchain/usr/bin",
    "swift.swiftEnvironmentVariables": {
        "DEVELOPER_DIR": "/Users/jakepetroules/Library/Developer/Xcode/DerivedData/Xcode-bciqhkcgebcelmdmrkdwpisviqpz/Build/Products/Debug/Xcode.app/Contents/Developer"
    }

...so it's failing because the DEVELOPER_DIR is invalid.

As a workaround, I can manually set it to the right value.

Environment

  • OS: macOS 15.4
  • Swift version Apple Swift version 6.1 (swift-6.1-RELEASE) Target: arm64-apple-macosx15.0
  • Visual Studio Code version: Version: 1.98.2 (Universal)
  • vscode-swift version: 2.2.0

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions