golem-add-rust-crate

Adds Rust crate dependencies to Golem WebAssembly component projects.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill golem-add-rust-crate
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golem-add-rust-crate
Source: https://github.com/golemcloud/golem/tree/main/golem-skills/skills/rust/golem-add-rust-crate
Command: npx skills add https://github.com/golemcloud/golem --skill golem-add-rust-crate

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding third-party crates to a Golem Rust project is risky because the compilation target is wasm32-wasip2, and many crates using threads, native system calls, or std::net will fail to compile. This Skill guides the correct way to add a dependency and verify it builds.

Core Features & Use Cases

  • Dependency Addition: Adds crates to the component's Cargo.toml, with support for Cargo workspace dependency management.
  • WASM Compatibility Guidance: Explains which crate categories work on wasm32-wasip2 and how to recover from build failures using wasm/wasi feature flags or alternative crates.
  • Build Verification: Runs golem build to confirm the new dependency compiles for the WebAssembly target.
  • Use Case: You want JSON schema validation in your Golem agent. Add the crate to Cargo.toml, run golem build, and if it fails, follow the guidance to find a WASM-compatible alternative.

Quick Start

Add the serde_yaml crate to my Golem Rust component and verify it builds.

Frequently Asked Questions about golem-add-rust-crate

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a crate dependency to a Golem Rust project?

Add the crate under [dependencies] in the component's Cargo.toml, then run golem build --yes to verify it compiles. If the project uses a Cargo workspace, declare the version in [workspace.dependencies] and reference it with workspace = true.

Which Rust crates work with wasm32-wasip2?

Pure Rust crates and crates supporting wasm32-wasi generally compile for wasm32-wasip2. Crates using threads, native system calls, mmap, std::net networking, or platform-specific C libraries will not compile.

Why does my crate fail to compile in a Golem project?

Build failures usually mean the crate depends on unsupported target features or C libraries incompatible with wasm32-wasip2. Try enabling a wasm or wasi feature flag if the crate offers one, or switch to a WASM-compatible alternative crate.

Can I use std::net or reqwest for HTTP in Golem Rust components?

No, std::net is not available on the WASM target. Use wstd::http for HTTP requests, since wstd is the WASI standard library already included in Golem Rust projects.

Should I run cargo build or golem build to test dependencies?

Always run golem build --yes, never cargo build directly. The golem build command compiles for the correct wasm32-wasip2 target and validates the component properly.