holochain-rust
holochain-rust copied to clipboard
kebab-case zomes fail to compile
Steps to reproduce:
-
hc init my-dna
-
cd my-dna
-
hc generate zomes/kebab-case
-
hc package
Output:
> CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-/tmp/my_first_app/target} && echo $CARGO_TARGET_DIR
"CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-/tmp/my_first_app/target} && echo $CARGO_TARGET_DIR "
/home/paul/target
> CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-/tmp/my_first_app/target} && cargo build --release --target=wasm32-unknown-unknown --target-dir=$CARGO_TARGET_DIR
"CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-/tmp/my_first_app/target} && cargo build --release --target=wasm32-unknown-unknown --target-dir=$CARGO_TARGET_DIR"
Updating crates.io index
Compiling kebab-case v0.1.0 (/home/paul/Holochain/kebab-test/zomes/kebab-case/code)
Finished release [optimized] target(s) in 2.79s
> CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-/tmp/my_first_app/target} && wasm-gc $CARGO_TARGET_DIR/wasm32-unknown-unknown/release/kebab-case.wasm
"CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-/tmp/my_first_app/target} && wasm-gc $CARGO_TARGET_DIR/wasm32-unknown-unknown/release/kebab-case.wasm"
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:999:5
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: wasm_gc::main
7: std::rt::lang_start::{{closure}}
Error: Couldn't traverse DNA in directory "/home/paul/Holochain/kebab-test": command CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-/tmp/my_first_app/target} && wasm-gc $CARGO_TARGET_DIR/wasm32-unknown-unknown/release/kebab-case.wasm was not successful
As you can see, it compiles fine, but then when wasm-gc
looks for the artifact kebab-case.wasm
it can't find it. Looking in the target dir, it exists as kebab_case.wasm
. Seems that cargo and rustc default to snake_casing the build artifact's filename, and there's no way for cargo to pass an explicit filename to rustc yet.
Suggested fix: do some magic string munging in hc generate
to make sure the .hcbuild
file always looks for a snake_case build artifact, but that feels fragile because it relies on upstream behaviour that's subject to change.
Another suggested fix: just enforce snake_case from the get-go.