Init hook panic

Hi there,
was interested to see if i could commit an anchor entry in the init hook of the zome… … i got a panic message after hc package:

    thread 'main' panicked at 'Failed to instantiate module: Function("host module doesn\'t export function with name _ZN3hdk10global_fns10write_json17h75a7ef5ec08f4291E")', src/libcore/
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::rust_panic_with_hook
   2: std::panicking::continue_panic_fmt
   3: rust_begin_unwind
   4: core::panicking::panic_fmt
   5: core::result::unwrap_failed
   6: holochain_core::nucleus::ribosome::run_dna::run_dna
   7: hc::cli::package::Packager::bundle_recurse
   8: hc::cli::package::Packager::bundle_recurse
   9: hc::cli::package::package
  10: hc::run
  11: hc::main
  12: std::rt::lang_start::{{closure}}
  13: main

it could be that my rust is wrong…
any help appreciated

Hmm, judging by the phrase “host module” I’d say that this is a problem in the WASM compilation step. It’s looking for a piece of the HDK that’s missing. Can I ask you how you installed your dev environment, and what you see when you type in hc --version?

hey @pauldaoust, thanks for reply… my environment is pretty standard setup. I am able to hc package fine etc…
using holochain 0.0.34-alpha1 + holonix 0.0.39

i will try to repeat the code in a later version and see if it works

best of luck; let me know how it goes. The last few holonix releases pushed to had have some package-related issues.

There’s a new release on holonix that might be worth a try.

This means that your WASM module defines an import _ZN3hdk10global_fns10write_json17h75a7ef5ec08f4291E - i.e. it expects to be linked with something that provides an according export of that same name. Since Holochain runs the DNA WASM modules alone, without any other module, it could only be provided by the runtime, i.e. the host module.

The Holochain host module only provides implementations of the HDK API functions, which should be the only imports defined by a proper DNA WASM. The fact that your DNA WASM has this import is the problem. I can’t say much about the reason for this without seeing your Cargo.toml. Also, the toolchain with which you’ve compiled the WASM might be causing this. Are you compiling from a Holonix nix-shell?

You can see those imports (and exports) of a WASM module with wasm-objdump, which is part of WABT.