spin icon indicating copy to clipboard operation
spin copied to clipboard

Rust instructions don't tell how to cargo init the project

Open technosophos opened this issue 2 years ago • 2 comments

The docs do not say how to cargo init a project. If you are doing a cargo init for a spin package, you need to do cargo init --lib and then it appears that at minimum you need to add the following to your Cargo.toml:

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

[dependencies]
# Useful crate to handle errors.
anyhow = "1"
# Crate to simplify working with bytes.
bytes = "1"
# General-purpose crate with common HTTP types.
http = "0.2"
# The Spin SDK.
spin-sdk = { git = "https://github.com/fermyon/spin" }
# Crate that generates Rust Wasm bindings from a WebAssembly interface.
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "2f46ce4cc072107153da0cefe15bdc69aa5b84d0" }

(I'm not entirely sure whether anyhow is actually required. It probably is not. But leaving out any of the rest causes the macros to barf.)

technosophos avatar Apr 04 '22 23:04 technosophos

This is primarily intended to be covered by templates (ref #186 and #273), but I can also see the appeal in having a documentation section describing how to initialize from scratch.

radu-matei avatar Apr 05 '22 05:04 radu-matei

Yeah, if the templates take care of it, that's fine.

technosophos avatar Apr 06 '22 00:04 technosophos

The templates do take care of it, so closing. Please reopen if anyone feels we should publish manual instructions too!

itowlson avatar Sep 22 '22 00:09 itowlson