Error starting the swift repl on windows

I've been eager to start working with Swift on Windows, and I have gone through the installation instructions. However, when starting the repl using swift repl -target x86_64-unknown-windows-msvc %SWIFTFLAGS% as instructed by the getting started page, I get the following error:

Expected<T> must be checked before access or destruction.
Unchecked Expected<T> contained error:
TypeSystem for language swift doesn't existStack dump:
0.      Program arguments: C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\lldb.exe --repl=-disable-objc-interop -sdk "C:\\Library\\Developer\\Platforms\\Windows.platform\\Developer\\SDKs\\Windows.sdk" -color-diagnostics -autolink-library oldnames -autolink-library msvcrt -Xcc -D_MT -Xcc -D_DLL

I get the same error just starting with swift.
I have tried the x64 Native Tools Command Prompt, Powershell, and cmd (all as admin).
I am able to compile and do things like swift --version, but I cannot import SwiftWin32 (probably unrelated) which leads me to believe that the problem lies somewhere with python. I have installed the vs version of python and added that to my path, and I also had other versions of python installed and in my path as well.

If anyone knows how to fix this or what is going on, I would be grateful.

1 Like

@PseudonymPatel, I think at least one part of the issue you're experiencing is that there is a known bug regarding the REPL that is preventing it from working on Windows (see SR-13591). From what I've heard, it sounds like this might be fixed in time for the 5.3.1 release.

The other part is probably installation/environment related. I had a few issues getting setup myself, but after following the installation instructions to the 'T', I finally got things working to where I could invoke swiftc directly. Below is info on my environment just in case it helps you.

Windows 10 build: 18362.1082
Build tools version: MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.27)
Windows SDK installed: 10.0.18362.0
Python version: 3.7.8

One thing I had trouble with was that I didn't copy the Support Files at the right time. You need to be sure to copy those after installing (or updating) the Swift toolchain or after any update to Visual Studio (also, be sure to do that as an administrator from the x64 Native Tools Command Prompt for VS). It's also worth trying to restart your machine after copying the Support Files if it still doesn't work.

For more context of my particular scenario, here's a link to an issue thread where I received some help working through some of the initial issues I was experiencing.


@PseudonymPatel, here’s another thread that may help. In it, there’s some discussion of the current issues with the REPL, as well as how to invoke swiftc directly.

This one helped me a little, too.

Terms of Service

Privacy Policy

Cookie Policy