holochain / holochain-rust

DEPRECATED. The Holochain framework implemented in rust with a redux style internal state-model.
GNU General Public License v3.0
1.12k stars 268 forks source link

kebab-case zomes fail to compile #2177

Open pdaoust opened 4 years ago

pdaoust commented 4 years ago

Steps to reproduce:

  1. hc init my-dna
  2. cd my-dna
  3. hc generate zomes/kebab-case
  4. 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.

pdaoust commented 4 years ago

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.