Swift failing to clone `swift-tools-support-core` on second invocation

I have a project that uses the new Swift 5.6 Plugin API (full code at GitHub - GeorgeLyon/PluginExample). The first time I run it (swift run UsesPlugin after removing .build), it works fine but the second time I run it consistently gives me the following error:

error: Failed to clone repository https://github.com/apple/swift-format:
    fatal: repository '/Volumes/Shared/Developer/Projects/PluginExample/.build/repositories/swift-format-e22a7199' does not exist
Creating working copy for https://github.com/apple/swift-argument-parser.git
error: Failed to clone repository https://github.com/apple/swift-argument-parser.git:
    fatal: repository '/Volumes/Shared/Developer/Projects/PluginExample/.build/repositories/swift-argument-parser-59ba1edd' does not exist
Creating working copy for https://github.com/apple/swift-tools-support-core.git
error: Failed to clone repository https://github.com/apple/swift-tools-support-core.git:
    fatal: repository '/Volumes/Shared/Developer/Projects/PluginExample/.build/repositories/swift-tools-support-core-1e273aae' does not exist
Creating working copy for https://github.com/apple/swift-syntax
error: Failed to clone repository https://github.com/apple/swift-syntax:
    fatal: repository '/Volumes/Shared/Developer/Projects/PluginExample/.build/repositories/swift-syntax-e33d5ec5' does not exist

I'm on macOS 12.3 using Swift 5.6 from Xcode 13.3. Is this a bug or am I doing something wrong?

It looks like the repo problem is solved by depending on swift-tools-support-core:

  dependencies: [
    .package(
      url: "https://github.com/apple/swift-tools-support-core.git",
      branch: "release/5.6")
  ]
...
    .product(name: "SwiftToolsSupport", package: "swift-tools-support-core"),

Unfortunately, this introduces a new error, this time only on the first invocation of swift run UsesPlugin

Undefined symbols for architecture x86_64:
  "_$s10UsesPlugin3fooyyF", referenced from:
      _UsesPlugin_main in main.swift.o
ld: symbol(s) not found for architecture x86_64

In this case, the function foo is defined the generated source, which the compiler does see (because it would fail in compilation otherwise), but the linker needs a second run in order to pick up.