Closed moznion closed 1 year ago
@moznion Sorry for late reply.
We reviewed your example and found some incorrect places. The revised version is
use wasmedge_sdk::{
config::{CommonConfigOptions, ConfigBuilder, HostRegistrationConfigOptions},
params,
plugin::PluginManager,
VmBuilder,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// load plugins from the default plugin path: $HOME/.wasmedge/plugin
PluginManager::load(None)?;
let wasm_app_file = std::env::args().nth(1).expect("Please specify a wasm file");
let config = ConfigBuilder::new(CommonConfigOptions::default())
.with_host_registration_config(HostRegistrationConfigOptions::default().wasi(true))
.build()?;
assert!(config.wasi_enabled());
let mut vm = VmBuilder::new()
.with_config(config)
.with_plugin_wasi_crypto()
.with_plugin("rustls", "rustls_client")
.build()?;
vm.wasi_module_mut()
.expect("Not found wasi module")
.initialize(None, None, None);
vm.register_module_from_file("wasm-app", &wasm_app_file)?
.run_func(Some("wasm-app"), "_start", params!())?;
Ok(())
}
The contents of $HOME/.wasmedge/
:
ubuntu@ip-172-31-31-132:~/.wasmedge$ pwd
/home/ubuntu/.wasmedge
ubuntu@ip-172-31-31-132:~/.wasmedge$ tree .
.
├── bin
│ ├── wasmedge
│ └── wasmedgec
├── env
├── include
│ └── wasmedge
│ ├── enum.inc
│ ├── enum_configure.h
│ ├── enum_errcode.h
│ ├── enum_types.h
│ ├── int128.h
│ ├── version.h
│ └── wasmedge.h
├── lib
│ ├── libwasmedge.so -> libwasmedge.so.0
│ ├── libwasmedge.so.0 -> libwasmedge.so.0.0.3
│ └── libwasmedge.so.0.0.3
└── plugin
├── libwasmedgePluginWasiCrypto.so
├── libwasmedgePluginWasiNN.so
└── libwasmedge_rustls.so
5 directories, 16 files
@apepkuss Thank you for your reply. I tweaked my code by adding PluginManager::load(None)?;
and replacing wasmedge_rustls
by rustls
, the it worked as expected.
I appreciate your precise advice.
I installed WasmEdge according to the following,
And I wrote a code to execute the wasm file by using wasmedge_sdk like the below:
then executed this program, it raises
Error: Plugin(NotFound("wasmedge_rustls"))
runtime error.As far as I checked, the plugin file is located the legit place:
And I also checked the behavior with
VmBuilder#with_plugin_wasi_crypto()
instead of#with_plugin()
, the result was the same:Error: Plugin(NotFound("wasi_crypto"))
.Is there any workaround?
FYI: I tested the same wasm file with
wasmedge
command line, that worked fine.Environment
Linux moznion-x1-ubuntu 6.2.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 6 10:23:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux