Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

kebab-case zomes fail to compile #2177

Open
pdaoust opened this issue Apr 10, 2020 · 1 comment
Open

kebab-case zomes fail to compile #2177

pdaoust opened this issue Apr 10, 2020 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@pdaoust
Copy link
Collaborator

pdaoust commented Apr 10, 2020

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 pdaoust added bug Something isn't working good first issue Good for newcomers labels Apr 10, 2020
@pdaoust
Copy link
Collaborator Author

pdaoust commented Apr 10, 2020

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.

@pdaoust pdaoust changed the title snake-case zomes fail to compile kebab-case zomes fail to compile Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant