Skip to content

blog: Running Wasm Components From the Command Line (approved) #126

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

Merged

Conversation

tpmccallum
Copy link
Contributor

@tpmccallum tpmccallum commented Apr 4, 2025

This is an article demonstrating how to use the wasmtime run --invoke feature. It explains WAVE syntax and implements a component with an exported function that is invoked in the Wasmtime CLI.

Relates to Zulip chat at #wasmtime > Article announcing the new `--invoke` feature. @ 💬

Related GitHub URLs:

tpmccallum and others added 2 commits April 5, 2025 09:54
Great point, thanks so. much!

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
Copy link
Contributor

@vados-cosmonic vados-cosmonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @tpmccallum thanks for writing this, this is an awesome intro to how to use wasmtime --invoke! I left a bunch of comments but feel free to take or leave any of them -- most are almost NIT level.

I know that trying to strike the balance between technical and approachable is absolutely devilish to pull off so feel free to ignore any overly technical points I made!

tpmccallum and others added 3 commits April 6, 2025 15:25
Co-authored-by: Victor Adossi <123968127+vados-cosmonic@users.noreply.github.com>
Co-authored-by: Victor Adossi <123968127+vados-cosmonic@users.noreply.github.com>
Copy link
Contributor

@vados-cosmonic vados-cosmonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hard work here -- I still have a few comments, but feel free to take/leave them!

Copy link
Collaborator

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great introductory blog post - thank you very much @tpmccallum for all your help getting the invoke PR across the finish line, and for writing this up!

Copy link
Contributor

@vados-cosmonic vados-cosmonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes @tpmccallum

On the interface/raw function export change, I think the --invoke invocation would change, so if you decide to take that change then running through it just once more is probably worth doing :)

@tpmccallum
Copy link
Contributor Author

Thanks, @pchickey
Absolute pleasure! Congratulations on implementing such a great feature.

Thanks, @vados-cosmonic
I have updated the example to include the best practice of using the interface approach.
Further, I gave the article one final read-through and tested all the code and configuration (.wit, .rs, .toml, etc.) on the latest wasmtime commit. Works like a charm 💯

wasm_answer % wasmtime --version
wasmtime 33.0.0 (4d0a43fd0 2025-04-14)
wasm_answer % cargo component build --target wasm32-wasip2 --release                            
  Generating bindings for wasm_answer (src/bindings.rs)
    Finished `release` profile [optimized] target(s) in 0.01s
wasm_answer % wasmtime run --invoke 'get-answer()' target/wasm32-wasip2/release/wasm_answer.wasm
42

Please let me know if you need me to tweak the date in the .md or the file name's date (regarding the publish date). I am happy with it from my end and looking forward to this publishing when practicable for wasmtime release schedule etc.

Chat soon
Tim

@vados-cosmonic
Copy link
Contributor

Thanks for really putting in the work here @tpmccallum -- this is going to be an amazing entry point for people into the ecosystem.

@tpmccallum tpmccallum changed the title Adding draft article re: wasmtime run --invoke blog: Running Wasm Components From the Command Line (approved) Apr 24, 2025
Just setting the `date` frontmatter to a future publishing date.
Copy link
Collaborator

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only marking this as "request changes" because I think we need to delay publishing until Wasmtime 33 is out. Also, I believe the policy is we need someone on the TSC to sign this off? one of @ricochet @ospencer @abrown @tschneidereit please

* [Rust](https://www.rust-lang.org/tools/install) (if you already have Rust installed, make sure you are on [the latest version](https://github.com/rust-lang/rust/releases)),
* [`cargo`](https://crates.io/crates/cargo) (if already installed, please make sure you are on [the latest version](https://crates.io/crates/cargo)),
* [`cargo component`](https://crates.io/crates/cargo-component) (if already installed, please make sure you are on [the latest version](https://crates.io/crates/cargo-component)), and
* [`wasmtime` CLI](https://docs.wasmtime.dev/cli-install.html) (or use a [precompiled binary](https://docs.wasmtime.dev/cli-install.html#download-precompiled-binaries)). If already installed, ensure you are using [the latest version](https://github.com/bytecodealliance/wasmtime/releases).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should wait to publish this until Wasmtime 33 is out - invoke didnt make it into the Wasmtime 32 release. I'd amend this to say it requires wasmtime 33 specifically, rather than the latest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pchickey
I have updated the filename and the date in the frontmatter to align with the next expected release.
I have also updated the wasmtime section to specify v33.0.0 or newer.
Changes are in cb41248.
Ready for sign off cc: @ricochet @ospencer @abrown @tschneidereit.
Kind regards
Tim

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tpmccallum and I have talked about this but for anyone else wondering: this is on the agenda for the next TSC meeting (no hurry since we expect it to be published later in May).

@tpmccallum tpmccallum requested a review from pchickey April 29, 2025 22:17
Copy link
Member

@abrown abrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was discussed today in the TSC and we are all in favor of this being merged once Wasmtime v33 is out. Thanks again for working on this!

Copy link
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be an excellent addition to the blog; thanks @tpmccallum for writing, and thank you to the others for their thorough reviews!

@abrown abrown merged commit 25263d4 into bytecodealliance:gh-pages May 21, 2025
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

Successfully merging this pull request may close these issues.

6 participants