Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Swift Script command doesn't work on Windows #423

Open
svanimpe opened this issue Sep 27, 2022 · 8 comments
Open

Run Swift Script command doesn't work on Windows #423

svanimpe opened this issue Sep 27, 2022 · 8 comments
Labels
bug Something isn't working windows Issue specific to Windows

Comments

@svanimpe
Copy link
Contributor

The "swift: Run Swift Script" command doesn't work on Windows, as is to be expected.
It shows the same error as when running swift file.swift on the command line:

<unknown>:0: error: could not load the swift standard library

Environment: Swift 5.7 on Windows 11

@svanimpe svanimpe added the bug Something isn't working label Sep 27, 2022
@stevapple
Copy link
Contributor

stevapple commented Sep 27, 2022

Seems to duplicate #416 (comment)?

It should be a Swift Driver bug which is pure toolchain-related. Once the Swift Driver bug is fixed, we should be able to use the feature.

@adam-fowler adam-fowler added the windows Issue specific to Windows label Sep 27, 2022
@dharmatech
Copy link

dharmatech commented Feb 11, 2023

Also running into the same issue.

I can run swiftc successfully at a PowerShell prompt:

image

However, if I use the Run Swift Script command in vscode, I get the following:

image

I noticed the following settings:

image

I tried setting the SDK to:

C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk

and the Runtime Path to:

C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\windows

and

C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift

however, setting those don't appear to resolve the issue.

@adam-fowler
Copy link
Contributor

The last time I looked running swift scripts on Windows was broken ie running swift <file>. @compnerd should be able to give us the latest details on that. Maybe they are fixed in the 5.8 development build.

@compnerd
Copy link
Member

No, the underlying issue is LLDB, not Swift. There has been no one who has stepped up to help work on LLDB, so this is still not available.

@dharmatech
Copy link

dharmatech commented Feb 14, 2023

Just wanted to clarify.

Compiling and running

Compiling with swiftc at a PowerShell prompt works fine and the resulting executable works:

image

Here's the output from evaluating that code:

image

Running with swift

However, running test.swift directly via swift at a PowerShell prompt

image

runs into the issue:

image

Test file

The file test.swift contains:

print("abc")

Comments

Since the same error is occurring at the prompt when using swift directly, it seems as if the issue may not be with vscode-swift, but in some other place.

@compnerd
Copy link
Member

@dharmatech correct. swift ... is running the swift file as a script, which runs it through the interpreter, which is using LLDB. swift compiles the code, doesn't interpret it.

@Taschi120
Copy link

Do I understand the above comments correctly: Running Swift with LLDB is not currently possible on Windows at all, and Swift code thus cannot be debugged on Windows?

@adam-fowler
Copy link
Contributor

Do I understand the above comments correctly: Running Swift with LLDB is not currently possible on Windows at all, and Swift code thus cannot be debugged on Windows?

No this is about running swift as a script. You can use LLDB to debug Swift executables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows Issue specific to Windows
Development

No branches or pull requests

6 participants