Getting started with a hApp

Yeah sorry about the threadjacking lol! I do believe it’s better to get these issues out in the open though, so thanks for understanding!

You might want to do a CTRL-refresh or whatever it takes to clear the cache and see if you’re getting the same problem as I’ve done some changes over the last few days including one where a link was to “beginner” instead of “basic” so that fixed one link, plus I noticed the sample code had #[hdk_extern] in it already but the tutorial was telling you to add it, so I thought the best thing to do was to remove it from the sample code and keep to what the tutorial was saying - perhaps you were caught up in the middle of those changes hence why it’s even more confusing!!

As for the error, I’ll let someone else far more knowledgeable than me respond to that, I haven’t tested mine since a few days ago before I started playing with the tutorial text as I noticed some inconsistencies that I wanted to iron out.

2 Likes

Yeyyyyy this is so awesome :smiley: Thank you both for the feedback and engaging, my hope has always been that the gym can be co-created at the rate that we all learn about holochain and work together, so seeing this is really great.

So yes, as @stephenpurkiss said you need to CTRL+R to clear the cache and then links should work as intended (I disabled the cache this past week so new versions won’t have that problem).

Yes, #[hdk_extern] should be in the code to expose it to the outer world, I’ll fix that, although the tryorama error seems to be about sth else. Let me take a look.

2 Likes

No, don’t “fix that” lol - I took it out because it was in there and the tutorial teaches you to put it in there but it was already in there. So we DON’T want it in there, unless you want to change the entire tutorial to remove teaching you to put it in there.

LOL :wink: Doesn’t anyone listen to me hah :wink:

Noo, @wwo is talking about the solution branch, which should contain the working solution for the exercise. The tutorial assumes you are working from the master branch, where that is not there.

2 Likes

OIC lol hah! I’m distracted with making my 5th call to my mum who can’t seem to ever figure out how to answer a call.

Yes it shouldn’t be there in the master branch now since I took it out last week, and it should be in the solution branch.

I’ll get me coat :wink:

1 Like

Oh I could have thought of that too so the website problem is solved :grinning:

2 Likes

Could the tryorama error be a false holochain version? I have installed it like described in https://github.com/holochain/holochain

nix-shell --argstr flavor happDev
cargo install --path crates/holochain
cargo install --path crates/hc
1 Like

Mmm that’s actually not the way that the developer exercises are meant to be run. You just need to run nix-shell wherever there is a default.nix file to get a full working environment with holochain and hc installed. This is also necessary to work with multiple holochain versions.

So, no need to clone and install from the core repository, if you follow the instructions in the readme of each gym exercise you should be able to get everything you need.

I am on a Mid-2012 MacBook Pro 15 Retina MacOS Catalina 10.15.7. It’s too old to update to latest MacOS but I see that isn’t working anyway right now lol :wink:

I followed the setup instructions here:

…and set up the holonix command as described here:
https://developer.holochain.org/docs/install-advanced/

./run_tests didn’t work for me, didn’t find hc so I tried @wwo’s link above, which seems to me to reinstall but also looks like it might set up hc. It’s currently horribly breaking and I’ve just seen @guillemcordoba’s reply so maybe he knows why hc is not found… cos I followed the instructions :wink: But I guess it could be MacOS specific, I do have an old X200 LibreBoot but it’s a bit loud and old and even slower than this hah.

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ ./run_tests --verbose
./run_tests: line 2: hc: command not found

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ hc
bash: hc: command not found

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ sudo hc
Password:
sudo: hc: command not found

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ holochain --version
holochain 0.0.100

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ holochain dna pack workdir && cd tests/ && npm install && npm test && cd ..
error: Found argument 'dna' which wasn't expected, or isn't valid in this context

USAGE:
    holochain [FLAGS] [OPTIONS]

For more information try --help

Wait, but did you run nix-shell inside the folder 0.entries? That’s the key step, maybe we should hightlight it a lot in the READMEs.

I ran holonix which is in the advanced setup as:

echo 'alias holonix=\'nix-shell https://holochain.love' >> ~/.bashrc
holonix

If you look at my comment above you’ll see:

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ hc
bash: hc: command not found

This is presumably saying “I’m in the nix-shell”.

I also successfully ran:

CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown

to compile my code, after running it previously and coming up with lots of errors that it couldn’t find core so then I figured out I’d forgotten to run holonix and that’s when I compiled it and it all went green and I was like “omg this is AMAZING!!!”. Then I tried to run the tests and it said it couldn’t find hc.

 ✘  ~/H/d/b/0.entries   master ±  nix-shell --version

nix-shell (Nix) 2.3.10
 ~/H/d/b/0.entries   master ±  holonix

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown
    Updating git repository `https://github.com/holochain/hc-utils`
    Updating crates.io index
  Downloaded constant_time_eq v0.1.5
  Downloaded num-traits v0.2.14
  Downloaded rand_core v0.5.1
  Downloaded arrayvec v0.5.2
  Downloaded ppv-lite86 v0.2.10
  Downloaded rand v0.7.3
  Downloaded cfg-if v0.1.10
  Downloaded num-integer v0.1.44
  Downloaded once_cell v1.5.2
  Downloaded matchers v0.0.1
  Downloaded sharded-slab v0.1.1
  Downloaded byteorder v1.4.2
  Downloaded proc-macro2 v1.0.24
  Downloaded itoa v0.4.7
  Downloaded tracing-attributes v0.1.12
  Downloaded tracing v0.1.23
  Downloaded pin-project-lite v0.2.4
  Downloaded libc v0.2.82
  Downloaded holochain_zome_types v0.0.2-alpha.1
  Downloaded lock_api v0.3.4
  Downloaded holochain_serialized_bytes_derive v0.0.50
  Downloaded tracing-core v0.1.17
  Downloaded serde_bytes v0.11.5
  Downloaded scopeguard v1.1.0
  Downloaded tracing-subscriber v0.2.15
  Downloaded rand_chacha v0.2.2
  Downloaded ansi_term v0.12.1
  Downloaded chrono v0.4.19
  Downloaded getrandom v0.1.16
  Downloaded derive_more v0.99.11
  Downloaded parking_lot v0.10.2
  Downloaded thiserror-impl v1.0.23
  Downloaded regex v1.4.3
  Downloaded syn v1.0.64
  Downloaded smallvec v1.6.1
  Downloaded rmp v0.8.9
  Downloaded regex-automata v0.1.9
  Downloaded serde-transcode v1.1.0
  Downloaded unicode-xid v0.2.1
  Downloaded strum v0.18.0
  Downloaded subtle v2.4.0
  Downloaded quote v1.0.8
  Downloaded unicode-segmentation v1.7.1
  Downloaded serde v1.0.123
  Downloaded thiserror v1.0.23
  Downloaded tracing-log v0.1.1
  Downloaded tracing-serde v0.1.2
  Downloaded paste v1.0.3
  Downloaded serde_derive v1.0.123
  Downloaded regex-syntax v0.6.22
  Downloaded ryu v1.0.5
  Downloaded rmp-serde v0.15.4
  Downloaded time v0.1.44
  Downloaded serde_json v1.0.61
  Downloaded log v0.4.14
  Downloaded heck v0.3.2
  Downloaded strum_macros v0.18.0
  Downloaded lazy_static v1.4.0
  Downloaded indexmap v1.6.1
  Downloaded holochain_wasmer_guest v0.0.67
  Downloaded blake2b_simd v0.5.11
  Downloaded holochain_serialized_bytes v0.0.50
  Downloaded base64 v0.13.0
  Downloaded holochain_wasmer_common v0.0.67
  Downloaded arrayref v0.3.6
  Downloaded thread_local v1.1.3
  Downloaded hashbrown v0.9.1
  Downloaded cfg-if v1.0.0
  Downloaded hdk v0.0.100
  Downloaded fixt v0.0.2-alpha.1
  Downloaded autocfg v1.0.1
  Downloaded parking_lot_core v0.7.2
  Downloaded holo_hash v0.0.2-alpha.1
  Downloaded hdk_derive v0.0.2-alpha.1
  Downloaded 74 crates (3.6 MB) in 1.50s
error: failed to open: /Users/steve/Holoplay/developer-exercises/basic/0.entries/target/release/.cargo-lock

Caused by:
  Permission denied (os error 13)

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ sudo rm -f /Users/steve/Holoplay/developer-exercises/basic/0.entries/target/release/.cargo-lock
Password:

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown
error: failed to open: /Users/steve/Holoplay/developer-exercises/basic/0.entries/target/release/.cargo-lock

Caused by:
  Permission denied (os error 13)

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ ls -la /Users/steve/Holoplay/developer-exercises/basic/0.entries/target/release/
total 0
drwxr-xr-x  7 root staff  224 Mar 22 15:30 .
drwxr-xr-x  6 root staff  192 Mar 22 15:23 ..
drwxr-xr-x 84 root staff 2688 Mar 22 15:23 .fingerprint
drwxr-xr-x 25 root staff  800 Mar 22 15:23 build
drwxr-xr-x 28 root staff  896 Mar 22 15:24 deps
drwxr-xr-x  2 root staff   64 Mar 22 15:23 examples
drwxr-xr-x  2 root staff   64 Mar 22 15:23 incremental

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ cd ..

[nix-shell:~/Holoplay/developer-exercises/basic]$ cd ..

[nix-shell:~/Holoplay/developer-exercises]$ cd ..

[nix-shell:~/Holoplay]$ sudo rm -rf developer-exercises/

[nix-shell:~/Holoplay]$ gh repo clone stephenbpurkiss/developer-exercises
Cloning into 'developer-exercises'...
remote: Enumerating objects: 566, done.
remote: Total 566 (delta 0), reused 0 (delta 0), pack-reused 566
Receiving objects: 100% (566/566), 5.56 MiB | 748.00 KiB/s, done.
Resolving deltas: 100% (234/234), done.
Updating upstream
From github.com:holochain-gym/developer-exercises
 * [new branch]      master     -> upstream/master

[nix-shell:~/Holoplay]$ cd developer-exercises/

[nix-shell:~/Holoplay/developer-exercises]$ cd basic/
0.entries/  1.hashes/   3.elements/

[nix-shell:~/Holoplay/developer-exercises]$ cd basic/0.entries/

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ ls
Cargo.lock  Cargo.toml	README.md  default.nix	run_tests  tests  workdir  zomes

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown
    Updating git repository `https://github.com/holochain/hc-utils`
    Updating crates.io index
  Downloaded syn v1.0.64
  Downloaded thiserror v1.0.23
  Downloaded time v0.1.44
  Downloaded byteorder v1.4.2
  Downloaded chrono v0.4.19
  Downloaded arrayref v0.3.6
  Downloaded thread_local v1.1.3
  Downloaded autocfg v1.0.1
  Downloaded thiserror-impl v1.0.23
  Downloaded heck v0.3.2
  Downloaded tracing-subscriber v0.2.15
  Downloaded unicode-xid v0.2.1
  Downloaded serde-transcode v1.1.0
  Downloaded itoa v0.4.7
  Downloaded lazy_static v1.4.0
  Downloaded num-traits v0.2.14
  Downloaded pin-project-lite v0.2.4
  Downloaded holochain_serialized_bytes v0.0.50
  Downloaded parking_lot v0.10.2
  Downloaded holochain_serialized_bytes_derive v0.0.50
  Downloaded matchers v0.0.1
  Downloaded log v0.4.14
  Downloaded parking_lot_core v0.7.2
  Downloaded scopeguard v1.1.0
  Downloaded rand_chacha v0.2.2
  Downloaded quote v1.0.8
  Downloaded regex-automata v0.1.9
  Downloaded tracing-core v0.1.17
  Downloaded tracing v0.1.23
  Downloaded ppv-lite86 v0.2.10
  Downloaded rand_core v0.5.1
  Downloaded unicode-segmentation v1.7.1
  Downloaded holochain_zome_types v0.0.2-alpha.1
  Downloaded regex v1.4.3
  Downloaded rmp-serde v0.15.4
  Downloaded hdk_derive v0.0.2-alpha.1
  Downloaded paste v1.0.3
  Downloaded subtle v2.4.0
  Downloaded ansi_term v0.12.1
  Downloaded hdk v0.0.100
  Downloaded getrandom v0.1.16
  Downloaded once_cell v1.5.2
  Downloaded lock_api v0.3.4
  Downloaded num-integer v0.1.44
  Downloaded derive_more v0.99.11
  Downloaded blake2b_simd v0.5.11
  Downloaded proc-macro2 v1.0.24
  Downloaded holo_hash v0.0.2-alpha.1
  Downloaded indexmap v1.6.1
  Downloaded tracing-attributes v0.1.12
  Downloaded constant_time_eq v0.1.5
  Downloaded serde_bytes v0.11.5
  Downloaded tracing-log v0.1.1
  Downloaded strum_macros v0.18.0
  Downloaded strum v0.18.0
  Downloaded sharded-slab v0.1.1
  Downloaded serde v1.0.123
  Downloaded cfg-if v1.0.0
  Downloaded serde_json v1.0.61
  Downloaded holochain_wasmer_guest v0.0.67
  Downloaded rmp v0.8.9
  Downloaded holochain_wasmer_common v0.0.67
  Downloaded fixt v0.0.2-alpha.1
  Downloaded hashbrown v0.9.1
  Downloaded regex-syntax v0.6.22
  Downloaded libc v0.2.82
  Downloaded cfg-if v0.1.10
  Downloaded rand v0.7.3
  Downloaded ryu v1.0.5
  Downloaded base64 v0.13.0
  Downloaded arrayvec v0.5.2
  Downloaded tracing-serde v0.1.2
  Downloaded serde_derive v1.0.123
  Downloaded smallvec v1.6.1
  Downloaded 74 crates (3.6 MB) in 2.68s
   Compiling proc-macro2 v1.0.24
   Compiling unicode-xid v0.2.1
   Compiling autocfg v1.0.1
   Compiling syn v1.0.64
   Compiling serde_derive v1.0.123
   Compiling serde v1.0.123
   Compiling libc v0.2.82
   Compiling ryu v1.0.5
   Compiling getrandom v0.1.16
   Compiling serde_json v1.0.61
   Compiling cfg-if v1.0.0
   Compiling byteorder v1.4.2
   Compiling lazy_static v1.4.0
   Compiling hashbrown v0.9.1
   Compiling unicode-segmentation v1.7.1
   Compiling itoa v0.4.7
   Compiling paste v1.0.3
   Compiling scopeguard v1.1.0
   Compiling smallvec v1.6.1
   Compiling cfg-if v0.1.10
   Compiling ppv-lite86 v0.2.10
   Compiling log v0.4.14
   Compiling strum v0.18.0
   Compiling regex-syntax v0.6.22
   Compiling arrayref v0.3.6
   Compiling pin-project-lite v0.2.4
   Compiling arrayvec v0.5.2
   Compiling constant_time_eq v0.1.5
   Compiling base64 v0.13.0
   Compiling subtle v2.4.0
   Compiling once_cell v1.5.2
   Compiling ansi_term v0.12.1
   Compiling num-traits v0.2.14
   Compiling indexmap v1.6.1
   Compiling num-integer v0.1.44
   Compiling tracing-core v0.1.17
   Compiling sharded-slab v0.1.1
   Compiling lock_api v0.3.4
   Compiling parking_lot_core v0.7.2
   Compiling heck v0.3.2
   Compiling blake2b_simd v0.5.11
   Compiling thread_local v1.1.3
   Compiling parking_lot v0.10.2
   Compiling time v0.1.44
   Compiling rand_core v0.5.1
   Compiling tracing-log v0.1.1
   Compiling quote v1.0.8
   Compiling regex-automata v0.1.9
   Compiling regex v1.4.3
   Compiling rand_chacha v0.2.2
   Compiling rmp v0.8.9
   Compiling rand v0.7.3
   Compiling chrono v0.4.19
   Compiling matchers v0.0.1
   Compiling thiserror-impl v1.0.23
   Compiling holochain_serialized_bytes_derive v0.0.50
   Compiling tracing-attributes v0.1.12
   Compiling strum_macros v0.18.0
   Compiling derive_more v0.99.11
   Compiling thiserror v1.0.23
   Compiling tracing v0.1.23
   Compiling serde_bytes v0.11.5
   Compiling rmp-serde v0.15.4
   Compiling serde-transcode v1.1.0
   Compiling tracing-serde v0.1.2
   Compiling holochain_serialized_bytes v0.0.50
   Compiling tracing-subscriber v0.2.15
   Compiling fixt v0.0.2-alpha.1
   Compiling holochain_wasmer_common v0.0.67
   Compiling holochain_wasmer_guest v0.0.67
   Compiling holo_hash v0.0.2-alpha.1
   Compiling holochain_zome_types v0.0.2-alpha.1
   Compiling hdk_derive v0.0.2-alpha.1
   Compiling hdk v0.0.100
   Compiling hc_utils v0.2.0 (https://github.com/holochain/hc-utils?branch=develop#f4b38f37)
   Compiling exercise v0.0.1 (/Users/steve/Holoplay/developer-exercises/basic/0.entries/zomes/exercise)
    Finished release [optimized] target(s) in 2m 55s

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ ./run_tests
./run_tests: line 2: hc: command not found

No yeah, but actually https://holochain.love is broken. This is why we are moving towards nix files and local setups rather than relying on changing external URLs. holochain.love is still pointing to a time where hc didn’t exist.

Being in a nix shell doesn’t mean having the right holochain dependencies installed. Think about the nix-shell as an environment builder: you can build full-fledged environments with all the dependencies you want there, only with a default.nix file. Depending on which default.nix file you execute, you’ll be in an environment or another.

2 Likes

OK, so I think I see what you’re saying, so I dropped out of nix-shell, went into the directory, back in, same issue:

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ exit
exit
 ✘  ~  cd ~/Holoplay/developer-exercises/basic/0.entries/
 ~/H/d/b/0.entries   master ±  holonix

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$ ./run_tests
./run_tests: line 2: hc: command not found

[nix-shell:~/Holoplay/developer-exercises/basic/0.entries]$

Which command did you run to enter the nix-shell inside the directory?

Ah, OK, so I didn’t know there was a difference between what I was doing typing holonix as it was in the setup guide as a shortcut to getting things up and running.

I set up holonix because in the first paragraph of the setup guide, the highlighted paragraph, it says:

If you like tinkering, read our advanced guide.

…now I don’t know what you think on this subject but I reckon anyone who is reading the setup guide probably likes tinkering, and probably likes saving time, so perhaps it might be good to change the setup guide for the gym, or the setup guide itself to say “oh by the way, DON’T DO THIS”.

Maybe, just maybe… lol :smiley:

So I guess I’ll try this nix-shell thing…

OK I’m just getting loads of errors now after typing nix-shell in the right directory so I’ve probably messed up my setup and will spend some time reinstalling. I’m close to putting Linux back on this mac to make life easier but I’m using it for Zoom and y’know, dual booting etc. I’ll just end up spending lots of time when I guess lots of people will be using macs and so will keep on this for the mo.
In case there’s anything recognisable I’m posting the errors below, I’ll try again after reinstalling.

   Compiling const-random-macro v0.1.13
   Compiling security-framework v2.1.1
error: linking with `/nix/store/sw7b2gcklaj3iy5ikv7ag163bpry3ivb-clang-wrapper-7.1.0/bin/cc` failed: exit code: 1
  |
  = note: "
---

  = note: ld: library not found for -liconv
          clang-7: error: linker command failed with exit code 1 (use -v to see invocation)


error: aborting due to previous error

error: could not compile `const-random-macro`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
builder for '/nix/store/gjds6y8dgzkymh0sh9bd22h04ffc1h7h-holochain.drv' failed with exit code 101
error: build of '/nix/store/gjds6y8dgzkymh0sh9bd22h04ffc1h7h-holochain.drv', '/nix/store/rv1q1h55jpjdacz572pc2bk4yg4g5m69-holochain.drv' failed

I did try this exercise again now, and it is working. ( I am on linux)
These are my steps:
1- I just have installed nix-shell (Nix) 2.3.10
2- I cloned the exercise and then in this folder run nix-shell here:

developer-exercises/basic/0.entries/$ nix-shell

3- then compile here:

developer-exercises/basic/0.entries/zomes/exercise]$ CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown

4- finally you should have these errors which means, build is working and you need to finish the solution as an excercise.

1 Like

Hmmm… I just googled the first error I get:

error: linking with /nix/store/sw7b2gcklaj3iy5ikv7ag163bpry3ivb-clang-wrapper-7.1.0/bin/cc failed: exit code: 1

…and got two results, one to:

holonix fails on big sur
https://www.gitmemory.com/issue/holochain/holonix/211/800743132

which is another issue being discussed on this forum, not sure why a link to this forum didn’t turn up but here’s the link, perhaps it’s not just a problem with Big Sur then cos my laptop’s too old for it!

Thanks I will try that. Just out of curiosity how long did it take you to compile until the nix shell was started?

For the first time it takes a lot of time to run nix-shell for me. you need to be patient.

But after the first time It is very fast.