holochain / scaffolding

Scaffolding tool to quickly generate and modify holochain applications
https://docs.rs/holochain_scaffolding_cli
221 stars 19 forks source link

integrity zome doesnt get created on an existing project (hc 0.4x) #349

Closed nphias closed 3 months ago

nphias commented 3 months ago

using nix 2.23 holochain / hc 0.4.0-dev12

note: I assumed that scaffolding tool is bundled with hc and no other installation procedure was needed running hc-scaffold --version and hc scaffold --version in the nix develop env i get holochain_scaffolding_cli 0.0.4

I tried running the scaffold tool on an existing project. it created a coordinator zome in my crates directory, updated root cargo.toml and the project dna.yaml but failed to create the integrity zome even though it claimed it had been scaffolded.. and then crashed with no error message It also messed with my root cargo.toml adding a bunch of other dependencies and old versions of the hdi,hdk

: hc scaffold zome ✔ Choose UI framework: · Lit ✔ What do you want to scaffold? · Integrity/coordinator zome-pair (recommended) ✔ Enter coordinator zome name (snake_case): (The integrity zome will automatically be named '{name of coordinator zome}_integrity') · external_attestation ✔ Scaffold integrity zome in folder "crates/"? · yes Integrity zome "my_zome_integrity" scaffolded! ✔ Scaffold coordinator zome in "crates/"? · yes Coordinator zome "my_zome" scaffolded! Updating crates.io index error: no matching package named my_zome_integrity found location searched: /Users/../crates/my_zome required by package my_zome v0.0.1 (/Users/../crates/my_zome) Error: cargo metadata exited with an error:

c12i commented 3 months ago

Hi there @nphias, thank you for reporting this issue.

I assumed that the scaffolding tool is bundled with hc and no other installation procedure was needed

The scaffolding tool is indeed bundled with holonix, and hc will execute hc-scaffold when you run hc scaffold, provided it's installed in the current environment. This should be the case if you are using Nix.

It appears the version of the scaffolding tool you're using (holochain_scaffolding_cli 0.0.4) is quite outdated. I'm curious to know which version of holonix you are running on your existing project. Could you please share your nix.flake file so I can investigate this further?

nphias commented 3 months ago
{
  inputs = {
    nixpkgs.follows = "holonix/nixpkgs";

    versions.url = "github:holochain/holochain/holochain-0.4.0-dev.12?dir=versions/weekly";
    holonix.url = "github:holochain/holochain/holochain-0.4.0-dev.12";
    holonix.inputs.versions.follows = "versions";
    holonix.inputs.holochain.url = "github:holochain/holochain/holochain-0.4.0-dev.12";
  };

  outputs = inputs@{ holonix, ... }:
    holonix.inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      # provide a dev shell for all systems that the holonix flake supports
      systems = builtins.attrNames holonix.devShells;

      perSystem = { config, system, pkgs, ... }:
        {
          devShells.default = pkgs.mkShell {
            inputsFrom = [ holonix.devShells.${system}.holochainBinaries ];
            packages = with pkgs; [
              # add further packages from nixpkgs
              # nodejs
              cargo-nextest
            ];
          };
        };
    };
}
c12i commented 3 months ago

Thanks for sharing. Tried to reproduce this on my end, here are my findings:

{
  inputs = {
    # ...
    holonix.inputs.scaffolding.url = "github:holochain/scaffolding/holochain-weekly";
  };

 # ...
nphias commented 3 months ago

yes deleted the flake.lock file added the override you suggested did nix flake update same verson output holochain_scaffolding_cli 0.0.4

ill try gc/clean on my nix cache/store.. pretty sure i did that recently :/

guillemcordoba commented 3 months ago

I think the issue is that you're only depending on the holochainBinaries in your flake.nix. I copied your flake.nix and ran nix develop with it and didn't give me the hc-scaffold binary. I bet your hc-scaffold binary is a system-wide old installation of the scaffolding tool. What's the output when you run which hc-scaffold? If that path is outside the /nix/store, that's the issue.

c12i commented 3 months ago

Good catch @guillemcordoba. It seems the scaffolding version that get's printed out is outside /nix/store. On uninstalling it and re-running hc scaffold --version inside the nix shell, I get Failed to run external subcommand: Os { code: 2, kind: NotFound, message: "No such file or directory" } and hc-scaffold: command not found.

I guess holochain_scaffolding_cli is not part of the holochainBinaries?

guillemcordoba commented 3 months ago

Exactly. It's part of the holonix devshell which is the default in most projects.

nphias commented 3 months ago

oh crap .. thanks @guillemcordoba @c12i .. i was using a random flake file.. yes it was using an old version in my ~/.cargo/bin folder. my bad closing this