Following Create new App tutorial fails

After installing hc and following instructions on https://developer.holochain.org/docs/create-new-app/

Errors out with:
Updating crates.io index
error: failed to select a version for serde.

Details:
[nix-shell:~]$ hc --version
hc 0.0.42-alpha5

@thedavidmeister any ideas?

Hi! It seems that the scaffold hc is generating zomes that points to 0.0.42-alpha5 (that depends on serde 1.0.89) but also to the newer serde 1.0.100, hence the conflict. This should be fixed in the cli. Meanwhile, you can change the generated Cargo.toml for your zome to this:

[dependencies]
serde = "=1.0.89"
serde_json = { version = "=1.0.39", features = ["preserve_order"] }
serde_derive = "=1.0.89"
hdk = "=0.0.42-alpha5"
holochain_wasm_utils = "=0.0.42-alpha5"
holochain_json_derive = "=0.0.17"

This should work.

1 Like

yeah i think @freesig was iterating on something here, potentially even need serde 1.0.104 (or will soon)

either way the generation is just coming from here i believe https://github.com/holochain/rust-proc-zome-template

Oh yeah - that was the first thing I tried and then I get a different Serde version error. Then it wants Serde version 1.0.39

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
error: failed to select a version for serde_json.
… required by package hdk v0.0.42-alpha5
… which is depended on by my_zome v0.1.0 (/Users/ajaxmac/Development/hc-app/new-app/zomes/my_zome/code)
versions that meet the requirements = 1.0.39 are: 1.0.39

all possible versions conflict with previously selected packages.

previously selected package serde_json v1.0.47
… which is depended on by my_zome v0.1.0 (/Users/ajaxmac/Development/hc-app/new-app/zomes/my_zome/code)

failed to select a version for serde_json which could resolve this conflict
Error: Couldn’t traverse DNA in directory “/Users/ajaxmac/Development/hc-app/new-app”: command CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-/tmp/my_first_app/target} && cargo build --release --target=wasm32-unknown-unknown --target-dir=$CARGO_TARGET_DIR was not successfu

What version of serde_json do you have in your Cargo.toml?

Hi @guillemcordoba,

It’s in the screengrab in my first post - it defaults to serde “=1.0.100”, which gives the error that 1.0.89 is requiredd. Changing serde version in Cargo.toml to “=1.0.89” produces the error that packaging requires version 1.0.39. For some reason. Also setting the version to 1.0.104 as @thedavidmeister mentioned doesn’t work either.

I think you may be mixin the serde and serde_json crates. serde has jump from 1.0.89 to 1.0.100/4, serde_json from 1.0.39 to 1.0.47. Can this be?

1 Like

yeah, this is frustrating, there’s an upstream issue where serde macros cannot be re-exported, so every single rust crate in the dependency tree needs to set serde versions correctly…

@guillemcordoba, I haven’t mixed anything. I installed holochain using nix-shell https://holochain.love and then tried to do the very first tutorial. So HC is shipping with this bug.

The Cargo.toml in tis case is:

[package]
name = "my_zome"
version = "0.1.0"
authors = ["hc-scaffold-framework"]
edition = "2018"

[dependencies]
serde = "=1.0.100"
serde_json = { version = "=1.0.47", features = ["preserve_order"] }
serde_derive = "=1.0.100"
hdk = "=0.0.42-alpha5"
hdk_proc_macros = "=0.0.42-alpha5"
holochain_wasm_utils = "=0.0.42-alpha5"
holochain_json_derive = "=0.0.21"

[lib]
path = "src/lib.rs"
crate-type = ["cdylib"]

Hi @ajaxmac! Definitely hc is currently shipping with a bug, I was not discussing that :slight_smile: . What I’m trying to say though is that, if you replace the contents of the Cargo.toml with the right serde dependencies, you can fix your zome and make it compile.

Replacing all the [dependences] with these ones:

And without any more serde or other crates in the dependencies in your Cargo.toml, works, at least for me.

1 Like

Ok cool I’ll give that a try.

1 Like

@guillemcordoba, It did indeed compile with the Cargo.toml that you provided. Thanks!

2 Likes

I will just chime in to say I’ve been dealing with these issues too! Hope we as hApp developers don’t have to be dealing so much with this.