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

issue when trying to run swift script. #416

Closed
Nytem opened this issue Sep 13, 2022 · 35 comments
Closed

issue when trying to run swift script. #416

Nytem opened this issue Sep 13, 2022 · 35 comments

Comments

@Nytem
Copy link

Nytem commented Sep 13, 2022

so I followed the getting started page for the windows installation (https://swift.org/getting-started/) but every time I try to run a swift script I get this popup.

image

any ideas what could be going on?

@stevapple
Copy link
Contributor

stevapple commented Sep 13, 2022

This is a known restriction of the legacy Swift driver. With the release of Swift 5.7, Swift has officially adopted the new driver on Windows, so this error should not appear any more with Swift 5.7+.

Give the new Swift 5.7 a shot and see if anything is different?

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

I did download swift 5.7 I believe, it was the latest one in the downloads section.

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

wait nope it's showing as 5.6.3??? mb

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

ok it ran but now I got this
image

@adam-fowler
Copy link
Member

@compnerd any ideas, what is happening here

@compnerd
Copy link
Member

That indicates that the environment is not correct (i.e. SDKROOT is unset). Most likely the shell/terminal emulator was not restarted after the update.

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

let me try restarting everything then quickly

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

@compnerd restarted everything and still getting the same issue

@compnerd
Copy link
Member

Run set SDKROOT and ensure that the path exists and is correct. I assume that you did do an uninstall + install for the upgrade?

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

yeah I uninstalled swift 5.6.3 and then installed 5.7

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

where do I enter that set SDKROOT, sorry I'm a little bit incompetent here lol, just my class for school requires swift and I own no apple devices so I'm just trying to get this working lol

@compnerd
Copy link
Member

You should be able to run that from a cmd prompt.

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

yeah ok a path does exist

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

@compnerd
Copy link
Member

I wonder if the problem is that the plugin is erasing the SDKROOT environment variable? @stevapple or @adam-fowler would know that better.

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

wonder if the standard library is even there perhaps? would you know what the name of the folder I should be looking for is?

@stevapple
Copy link
Contributor

@Nytem Did you see the error when manually running swift <script.swift> from a developer command prompt?

The plugin doesn't modify the environment without configuration (except for testing). I see this as something wrong with SDK/toolchain layout.

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

@stevapple I just right clicked, and then under swift I clicked run swift script

@compnerd
Copy link
Member

You will find the standard library swift module %SDKROOT%\usr\lib\swift\windows\Swift.swiftmodule, the import library at %SDKROOT%\usr\lib\swift\windows\x86_64, and the runtime in C:\Program Files\swift\runtime-development\usr\bin.

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

these all look correct?
image
image
image

@stevapple
Copy link
Contributor

@Nytem I just want to make sure that the toolchain works without the plugin. Run Swift Script is a very simple feature and it's unlikely to impact the driver.

Can you open x64 Native Tools Command Prompt from start menu, cd path\to\workspace, and manually run swift script.swift? A screenshot of the command outputs will help a lot.

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

@stevapple like this?
image

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

sorry for the blackouts, folders named somewhat personal info lol

@stevapple
Copy link
Contributor

stevapple commented Sep 13, 2022

@stevapple like this?

image

Almost right -- except that CMD doesn't specialize ', so you should use " to wrap the argument instead. Could you try again?

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

oh oops, will do

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

same issue
image

@compnerd
Copy link
Member

What if you do an explicit swift -sdk %SDKROOT% "..."?

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

exact same error

@compnerd
Copy link
Member

Hmm, running with -v might be useful to see what the driver is doing. In general, the interpreter is not supported on Windows, compiling and executing is.

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

image

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

so when following the getting started page, it said I needed python, if I type in python --version it doesn't detect anything... could that be the issue?

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

nope nvm, I just installed it all again, restarted everything, and still same standard library error

@stevapple
Copy link
Contributor

@compnerd Looks like the 5.7 driver is still trying to use interpreter. Did you recognize any commit possibly forgotten for cherry-picking to 5.7 branch?

@stevapple
Copy link
Contributor

@Nytem I reproduced the problem locally and this is a driver bug instead of the plugin’s. Could you please open a new issue in apple/swift-driver, so we can move on there? This issue can be closed then.

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

alright, will do. thanks for the help guys!

@Nytem
Copy link
Author

Nytem commented Sep 13, 2022

apple/swift-driver#1182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants