Swift on Windows - REPL does not start

Hello,

I have installed Swift on Windows 10 using the instruction from here

The installation went fine, but the REPL does not show up when I type swift command.

From the dev cmd from VS

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>swift --version
compnerd.org Swift version 5.3.3-dev (LLVM 3093af41dd, Swift 266905108e)
Target: x86_64-unknown-windows-msvc

The output of the swift command without any flags. Maybe no errors are displayed, but the repl does not start.

Windows version is
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.19042 N/A Build 19042

Thank you,
Cosmin

Silly me :grin:

It requires Python (3.9)

Perhaps the Python recommendation should be put mandatory, or a message when the user try the command without Python being installed. :)

Yes, that was a bug in the original 5.3 builds (that I was hesitant to repair). The 5.4 and development snapshots should actually use 3.7 as documented. The reason for the explicit versioning here is simply that Visual Studio has a bundled Python, and I think that there is some value in just having Visual Studio serve as the distribution mechanism for all of the dependencies. I could also see some value in distributing python along with the toolchain, but that would require some investigation into licensing and packaging.

Unfortunately, as lldb links against python, we cannot execute code in lldb without Python being present, so you cannot really display an error message. If the toolchain had a lldb built without Python, the display of types would not function.

The terminology there is borrowed from RFCs and Debian:

  • required: this is not an option
  • recommended: you really should install this, if you don't, things may not work

Thank you for the answer :)

I encountered this problem in December 2021 and still cannot resolve it. First, I had to do pip install six because it didn't have six.py installed. Then, REPL froze like @cosminpopescu14 mentioned. I had both Python 3.7.8 and Python 3.10.0 installed. I deleted Python 3.10.0 through Control Panel > Programs > Programs and Features. swift repl now returns this error:

C:/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swift.exe: error while loading shared libraries: api-ms-win-crt-locale-l1-1-0.dll: cannot open shared object file: No such file or directory

Calling python3 --version from Git Bash gave this error:

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

I disabled both the aliases for python.exe and python3.exe through Settings > Manage App Execution Aliases. swift repl returned the same error, but python3 --version returned:

bash: /c/Users/phili/AppData/Local/Microsoft/WindowsApps/python3: No such file or directory

I tried reinstalling Python 3.7.8 using winget install Python.Python.3 --version 3.7.8150.0 as instructed on Swift.org. There was a popup window that showed a progress bar indicating that something was installing. But the behavior did not change afterward.

I am using the 2022-05-04 development toolchain and Windows 10 Home (Version 21H2, OS build 19044.1645, Experience Windows Feature Experience Pack 120.2212.4170.0). @compnerd is there anything I can do to get REPL to work on Windows? I guess I should still be able to use swiftc and swift package to compile Swift. All I want to do is compile my fork of tensorflow/swift-apis, s4tf/s4tf, on Windows using a custom x10 binary. Will doing that fail because of the issues with Python?

Getting the REPL working will require some surgery in lldb. It’s going to be a fair amount of work to get that sorted out. However, there’s a follow on set of issues that will also need to be resolved is my expectation before the repl is stable. See the various previous posts that discuss that.

You should be able to compile swift-apis and swift-models though. The python issues seem like an installation issue, I don’t know what that might influence.