wasmerio/wasmer · error · anyhow::Error
unsupported Wasm C API import version: {version:?}
Error message
unsupported Wasm C API import version: {version:?} What it means
Wasmer's Wasm C API imports layer only supports version V0 of the Wasm C API. When a module (or embedder) declares a C API import version that is not compatible with V0, validate_supported bails with this error before any imports are registered. It is a forward-compatibility guard against newer/unknown C API versions.
Source
Thrown at lib/c-api-imports/src/lib.rs:131
Self {
version: module_wasm_c_api_version_used(module),
imported_memory_type,
imported_table_type,
resolve_module_sync,
func_env: None,
}
}
fn needs_imports(&self) -> bool {
self.version.is_some()
}
fn validate_supported(&self) -> Result<()> {
if let Some(version) = self.version
&& !WasmCAPIVersion::V0.is_compatible_with(version)
{
bail!("unsupported Wasm C API import version: {version:?}");
}
Ok(())
}
fn register_imports(&mut self, store: &mut StoreMut<'_>, io: &mut Imports) -> Result<()> {
self.validate_supported()?;
if self.version.is_none() {
return Ok(());
}
let func_env = FunctionEnv::new(
&mut *store,
WasmCapiEnv {
resolve_module_sync: self.resolve_module_sync.clone(),
..WasmCapiEnv::default()
},
);
self.func_env = Some(func_env.clone());View on GitHub (pinned to 8c4b9ee9d3)
Solutions
- Set the C API import version to V0 (or leave it as None to use the default)
- Rebuild/upgrade the embedding code so both sides agree on the V0 C API revision
- Upgrade Wasmer to a release that supports the requested C API version, if one exists
Example fix
// before let imports = WasmCApiImports::default().version(WasmCAPIVersion::V2); // after let imports = WasmCApiImports::default().version(WasmCAPIVersion::V0);
Defensive patterns
Strategy: validation
Validate before calling
if let Some(v) = imports.version() {
if !wasm_c_api_imports::WasmCAPIVersion::V0.is_compatible_with(v) {
return Err(format!("unsupported C API version {v:?}; use V0"));
}
} Type guard
fn is_supported_version(v: Option<WasmCAPIVersion>) -> bool {
v.map_or(true, |v| WasmCAPIVersion::V0.is_compatible_with(v))
} Try / catch
match result {
Err(e) if e.to_string().contains("unsupported Wasm C API import version") => retry_with_v0(),
other => other?,
} Prevention
- Always construct WasmCApiImports with version V0 or None
- Keep the wasm-c-api SDK headers in sync with the Wasmer version
- Pin Wasmer versions in your embedding to avoid silent C API revision bumps
When it happens
Trigger: Calling add_imports/register_imports on a WasmCApiImports instance whose `version` field is set to Some(v) where WasmCAPIVersion::V0.is_compatible_with(v) is false (e.g. a newer C API version enum value).
Common situations: Using a wasm-c-api header/SDK newer than the Wasmer build; embedding Wasmer behind a C API shim built against a different spec revision; misconfigured import builder passing an explicit version.
Related errors
- env.memory import for Wasm C API module is not a memory
- env.__indirect_function_table import for Wasm C API module i
- unimplemented operator {operator:?}
- `wasm_valtype_kind: argument is a null pointer
- not a `sys` backend!
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/bdd9fa1689afd105.
Report an issue: GitHub.