khuedoan / homelab

Fully automated homelab from empty disk to running services with a single command.
https://homelab.khuedoan.com
GNU General Public License v3.0
7.9k stars 704 forks source link

Command: make tools, error #139

Open brimdor opened 4 months ago

brimdor commented 4 months ago

Describe the bug

I have been using Homelab since 2022. I rebuilt to the current build of May 2023 and haven't updated since then. You have made a lot of changes since May 2023 so I decided to rebuild from scratch. I Wiped the controller device I use to run the build commands which in the process of using your latest, also wiped the nodes during the PXE boot. All good things. However, when I attempt to run 'make tools', I get the following error:

Status: Downloaded newer image for nixos/nix:latest
error:
       … while fetching the input 'git+file:///home/brimdor/homelab'

       error: opening Git repository '/home/brimdor/homelab': repository path '/home/brimdor/homelab/' is not owned by current user
make: *** [Makefile:30: tools] Error 1

I have no idea why this is happening, it is a fresh fork as well.

I have verified that my user, brimdor, has ownership of the path.

I do not know how to reproduce this behavior besides attempting to build a brand new setup.

Expected behavior

It's supposed to create the nix container and allow me to start the build process in it.

The last time I posted about a Nix issue, it was cache. That didn't apply here as there is no cache for the first run. I still ran the command you gave me last time: docker volume rm homelab-tools-cache homelab-tools-nix

brimdor commented 4 months ago

Git 2.35.2 was given a patch for CVE-2022-24765. This now requires you to set a safe directory configuration in the .git/config file. But it has to be done inside the container. I recommend doing this in runtime within with Makefile. Adjust the last line of the docker command to be an entrypoint.

tools:
    @docker run \
        --rm \
        --interactive \
        --tty \
        --network host \
        --env "KUBECONFIG=${KUBECONFIG}" \
        --volume "/var/run/docker.sock:/var/run/docker.sock" \
        --volume $(shell pwd):$(shell pwd) \
        --volume ${HOME}/.ssh:/root/.ssh \
        --volume ${HOME}/.terraform.d:/root/.terraform.d \
        --volume homelab-tools-cache:/root/.cache \
        --volume homelab-tools-nix:/nix \
        --workdir $(shell pwd) \
        --entrypoint /bin/sh \
        docker.io/nixos/nix -c "\
        git config --global --add safe.directory $(shell pwd) && \
        nix --experimental-features 'nix-command flakes' develop"
khuedoan commented 4 months ago

Thank you for reporting and providing the solution, I can reproduce this on my machine.

The tools container is convenient for users who do not have Nix installed, however I'm starting to think it's a leaky abstraction :thinking: (there have been a few Docker/Podman-specific issues that do not exist if we run Nix directly)