Stream: general

Topic: How to use wasmtime_wasi crate


view this post on Zulip celine santosh (Feb 26 2025 at 12:49):

Hi

I wanted to make small changes in wasmtime_wasi crate and use in my project
In that case I have copy pasted wasmtime_wasi folder from wasmtime repo into my project and use this crate instead of actualwasmtime_wasi crate. But I feel like it's not possible because the cargo.toml has many dependencies which reply on other crates inside wasmtime repo , which are not present as public crates in registry. So my approach is not feasible right?
I wanted to confirm it

view this post on Zulip Lann Martin (Feb 26 2025 at 13:43):

You might be able to use [patch]

view this post on Zulip celine santosh (Feb 26 2025 at 14:16):

In the cargo.toml file of wasmtime_wasi crate

[dependencies]
wasmtime = { workspace = true, features = ["component-model", "async", "runtime", "std"] }
anyhow = { workspace = true }
wiggle = { workspace = true, optional = true, features = ["wasmtime"] }
tokio = { workspace = true, features = ["time", "sync", "io-std", "io-util", "rt", "rt-multi-thread", "net"] }
bytes = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
cap-std = { workspace = true }
cap-rand = { workspace = true }
cap-fs-ext = { workspace = true }
cap-net-ext = { workspace = true }
cap-time-ext = { workspace = true }
io-lifetimes = { workspace = true }
fs-set-times = { workspace = true }
bitflags = { workspace = true }
async-trait = { workspace = true }
system-interface = { workspace = true}
futures = { workspace = true }
url = { workspace = true }
once_cell = { workspace = true }

[dev-dependencies]
tokio = { workspace = true, features = ["time", "sync", "io-std", "io-util", "rt", "rt-multi-thread", "net", "macros", "fs"] }
test-log = { workspace = true }
tracing-subscriber = { workspace = true }
test-programs-artifacts = { workspace = true }
tempfile = { workspace = true }
wasmtime = { workspace = true, features = ['cranelift', 'incremental-cache'] }

[target.'cfg(unix)'.dependencies]
rustix = { workspace = true, features = ["event", "fs", "net"] }

We have many dependencies on other crates as well which I will have to maintain a local copy in my project right. So this maintainenc ofe folders will go on which is not the right approach I guess.
I think better will be to fork the branch then.
SO I wanted to confirm this is not the right approach

view this post on Zulip Victor Adossi (Feb 26 2025 at 14:30):

Hey celine, the easiest way to probably do this is probably to clone wasmtime locally and point at it with a git dependency.

If you update all the dependencies in your app that come from that repo also as git dependencies, then you'll be able to work that way/make changes across the various crates

If you have a wasmtime fork you can make your own branch (or not) and then go from there

view this post on Zulip Joel Dice (Feb 26 2025 at 14:32):

Given that wasmtime-wasi is published to crates.io, and that crates.io only accepts crates whose dependencies are also published to crates.io, all its dependencies should be available there. You'll want to make sure your fork is based on a published release-* tag from the wasmtime repo rather than main since the latter may contain changes which have not yet been published.

Concretely, you'll want to change all those { workspace = true } versions to the version numbers in the Cargo.toml at the root of the wasmtime repo you forked from (or else create your own workspace).

view this post on Zulip Joel Dice (Feb 26 2025 at 14:33):

And yes, the approach Victor suggested is likely the easiest approach.

view this post on Zulip Victor Adossi (Feb 26 2025 at 14:42):

Oh also a small tweak -- you can of course use a regular old path dependencies if you're only doing local development

view this post on Zulip celine santosh (Feb 27 2025 at 10:02):

okay got it
But some crates not published in crates.io
For example test-programs-artifacts,
I get error
error: no matching package named test-programs-artifacts found

location searched: registry crates-io

view this post on Zulip Victor Adossi (Feb 27 2025 at 14:13):

So test-programs-artifacts are intentionally not published -- it contains programs that are for local testing, so it shouldn't be published to crates.io , and no lib in the ecosystem for using wasmtime depends on them


Last updated: Feb 28 2025 at 02:27 UTC