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

Rust template 2.1 fails on Windows #2190

Closed
itowlson opened this issue Dec 20, 2023 · 8 comments
Closed

Rust template 2.1 fails on Windows #2190

itowlson opened this issue Dec 20, 2023 · 8 comments
Milestone

Comments

@itowlson
Copy link
Contributor

Reported by a Discord user (https://discord.com/channels/926888690310053918/1186493596501803059/1186700173397721122).

Follow these steps on Windows (it works fine on Linux):

  1. Download and unzip Spin 2.1 from the GH release page, and install the 2.1 templates.

  2. Create an application using the http-rust template. The Cargo.toml looks like this:

[package]
name = "spin21test"
authors = ["itowlson <ivan.towlson@fermyon.com>"]
description = ""
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
anyhow = "1"
spin-sdk = { git = "https://github.com/fermyon/spin", tag = "v2.1.0" }

[workspace]
  1. Run spin build.

Expected behaviour

It builds.

Actual behaviour

A slew of errors, mostly "failed to resolve/cannot find type", but the first of which is:

error: expected `world`, `interface` or `use`, found '.'
            --> C:\Users\ivan\.cargo\git\checkouts\spin-91500438ac5656d2\4ca3a56\sdk\rust\./wit:1:1
             |
           1 | ../../wit
             | ^
  --> C:\Users\ivan\.cargo\git\checkouts\spin-91500438ac5656d2\4ca3a56\sdk\rust\src\lib.rs:24:5
   |
24 | /     wit_bindgen::generate!({
25 | |         world: "platform",
26 | |         path: "./wit",
27 | |     });
   | |______^

If I change the SDK reference to the crates.io reference (spin-sdk = "2.1") it works fine; but that is not what the template uses. (Although they should, once we get the scripts properly wrangled!)

@ogghead
Copy link
Contributor

ogghead commented Dec 27, 2023

I was able to reproduce by following the steps given (thank you!), and I was also able to reproduce the errors by building Spin directly on Windows with make build

Changing path: "./wit" to path: "../../wit" on this line referenced by the build error allowed my local build to succeed. I did not verify whether this change builds on Unix systems though. I do not have context on the wit file currently used as an intermediate - let me know if there is a reason that is needed! Otherwise, I am happy to publish a PR for this change tomorrow after the 9-5! Edit: Looks like this symlink was added to resolve an issue with cargo publish- #2151 (comment). One route could be to update templates to reference the published SDK crate rather than Spin repository artifacts.

I see that Windows is added to the build CI here - feels like this should already be caught in the CI step

@itowlson itowlson added this to the 2.2 milestone Jan 2, 2024
@itowlson
Copy link
Contributor Author

itowlson commented Jan 2, 2024

Adding this to the 2.2 milestone as a reminder to wrangle the scripts so the released templates reference crates.io instead of GH (which appears to fix this).

Although it would still be good to also fix on main, so that Windows folks could use canary templates. @fibonacci1729 are you the knowledgeable person for the Rust SDK WIT stuff?

@fibonacci1729
Copy link
Contributor

fibonacci1729 commented Jan 3, 2024

@itowlson Happy to help with any Rust SDK WIT stuff but from reading the above, it seems like the symlink created to link ./wit -> ../../wit isn't working on Windows as expected. As @ogghead mentions, i am befuddled by this not being caught in CI when building for windows.

Worst-case scenario here if we can't address the above would be to just (yet-again) create another copy of the wits into sdk/rust..... cc/ @vdice if you have any thoughts.

@itowlson
Copy link
Contributor Author

itowlson commented Jan 3, 2024

My guess would be that CI runs against the local SDK (path reference) rather than the remote SDK (git reference), I believe that Windows + Git + symlinks is a whole exciting world of hurt that Windows + symlinks alone is not. (Cf. the lengthy, nuanced. and occasionally terrifying answers on this SO post (although the post itself is not directly relevant to this situation).)

(Which is presumably why crates.io is fine - I'm guessing in that case the symlink is followed at publish time, so that when Windows downloads from crates.io the files are packaged in the right place.)

@vdice
Copy link
Member

vdice commented Jan 3, 2024

Worst-case scenario here if we can't address the above would be to just (yet-again) create another copy of the wits into sdk/rust..... cc/ @vdice if you have any thoughts.

I don't have any brighter ideas than this for unblocking Windows users when using the "main" git ref.

@vdice
Copy link
Member

vdice commented Jan 10, 2024

Note: with the forthcoming 2.2.0 release and thereafter, the Rust templates will use crate references rather than git (ref #2221). This should fix the issue for Windows users.

@itowlson
Copy link
Contributor Author

I've marked the 2.2 work involved as Done, but I'm leaving this open until 2.2 ships so that 2.1 users can find it!

@vdice
Copy link
Member

vdice commented Jan 31, 2024

Spin v2.2.0 is out and the corresponding Rust templates now pull in the spin-sdk via the "2.2.0" crate reference. (Note: you'll need to run spin templates upgrade after upgrading to Spin v2.2 to pull down the latest templates.) Closing for now but please let us know if other issues arise.

@vdice vdice closed this as completed Jan 31, 2024
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