Swift on Windows - Resolve Package Dependencies fail, build fail

I'm new to Swift. I really want to try the language at a hobby project, but have been hindered at the initial step on Windows.

I have Visual Studio 2022 installed with the relevant workloads.
I have Swift installed (6.0 main snapshot)
I have vscode installed with the Swift extension.

I created an executable with the tool in vscode.
Immediately, I get this problem in the screenshot below:

If I try to run swift build
I get the error below:

error: 'helloworld': Invalid manifest (compiled with: ["C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.0.0+Asserts\\usr\\bin\\swiftc.exe", "-vfsoverlay", "C:\\Users\\rober\\AppData\\Local\\Temp\\TemporaryDirectory.dFvG1j\\vfs.yaml", "-L", "C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.0.0+Asserts\\usr\\lib\\swift\\pm\\ManifestAPI", "-lPackageDescription", "-sdk", "C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Platforms\\6.0.0\\Windows.platform\\Developer\\SDKs\\Windows.sdk", "-libc", "MD", "-I", "C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Platforms\\6.0.0\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows", "-I", "C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Platforms\\6.0.0\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\x86_64", "-L", "C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Platforms\\6.0.0\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\x86_64", "-use-ld=lld", "-swift-version", "6", "-I", "C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.0.0+Asserts\\usr\\lib\\swift\\pm\\ManifestAPI", "-package-description-version", "6.0.0", "F:\\SwiftDev\\P1\\HelloWorld\\Package.swift", "-o", "C:\\Users\\rober\\AppData\\Local\\Temp\\TemporaryDirectory.fWcNOl\\helloworld-manifest.exe"])
error: compile command failed due to exception 3 (use -v to see invocation)
Assertion failed: VCTools.Layout == llvm::ToolsetLayout::VS2017OrNewer && "unsupported toolset layout (VS2017+ required)", file C:\Users\swift-ci\jenkins\workspace\swift-main-windows-toolchain\swift\lib\ClangImporter\ClangIncludePaths.cpp, line 524
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: C:/Users/rober/AppData/Local/Programs/Swift/Toolchains/6.0.0+Asserts/usr/bin/swift-frontend.exe -frontend -c -primary-file F:\\SwiftDev\\P1\\HelloWorld\\Package.swift -target x86_64-unknown-windows-msvc -disable-objc-interop -sdk C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Platforms\\6.0.0\\Windows.platform\\Developer\\SDKs\\Windows.sdk -I C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Platforms\\6.0.0\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows -I C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Platforms\\6.0.0\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\x86_64 -I C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.0.0+Asserts\\usr\\lib\\swift\\pm\\ManifestAPI -vfsoverlay C:\\Users\\rober\\AppData\\Local\\Temp\\TemporaryDirectory.dFvG1j\\vfs.yaml -swift-version 6 -package-description-version 6.0.0 -empty-abi-descriptor -Xcc -working-directory -Xcc F:\\SwiftDev\\P1\\HelloWorld -resource-dir C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.0.0+Asserts\\usr\\lib\\swift -module-name main -in-process-plugin-server-path C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.0.0+Asserts\\usr\\bin\\SwiftInProcPluginServer.dll -plugin-path C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.0.0+Asserts\\usr\\bin -plugin-path C:\\Users\\rober\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.0.0+Asserts\\usr\\local\\bin -o C:\\Users\\rober\\AppData\\Local\\Temp\\TemporaryDirectory.QLIbz3\\Package-1.o
1.      Swift version 6.0-dev (LLVM 7a0ecf027d00801, Swift 3ccbcfe8cd40ded)
2.      Compiling with the current language version
Exception Code: 0x80000003

Has anyone ran into and solved this problem?

So after trying various things it finally worked, but I can't confirm which action caused it to work.

I uninstalled a 2022 version of LLVM and installed the latest 18.x version. I don't think this had an effect because the problem still presented.

Somehow, my system Path environment variable was longer than 2047 characters. I reduced it by removing some entries and then the Swift tooling started working.

Welcome to Windows

2 Likes

AFAIK, macOS has 1024 characters max path length.

Welcome to... macOS? But also, the issue was not length of a file path, but instead the length of the "PATH" environment variable. On macOS 14, getconf ARG_MAX returns 1048576.

1 Like

The "PATH" environment variable is what I meant.

Maybe on macOS 14 the 1024 characters max length for the "PATH" environment variable is not the actual limit anymore, but it definitely was for older versions. On the other hand, maximum length of command-line arguments and maximum length of the "PATH" environment variable are different things.

Just tested by assigning an environment variable (in macOS zsh) 1 million characters... no problem at all echoing it back verbatim :man_shrugging:

1 Like