Repository: algorandfoundation/nodekit (language: go)

Issue:
🐛 Installing fails if user account is named "algorand"
**Describe the bug**
A fresh NodeKit install on Ubuntu in which the user account was already named `algorand` failed to install properly and did not produce a meaningful error.

**To Reproduce**
Steps to reproduce the behavior:
1. With a Linux user account `algorand`
2. Install NodeKit
3. `FATA: algod is not running`

**Expected behavior**
NodeKit could detect the user account and throw a descriptive error.

**Screenshots**
![image](https://github.com/user-attachments/assets/fa95d246-00d5-4baa-a62e-9ed38b5be5d7)

**Additional context**
User was able to build a new image with a different user account name and NodeKit worked fine.


Discussion / hints:
Default systemd service runs algod with `user=algorand` - very likely related

We'll see what we can do. Worst case scenario we just warn people who have this username
We are unlikely to be able to do something about this, as we don't want to delve into "changing systemd service file" territory.

@dliptak001 The fix I would recommend is to [rename the user account AND group](https://serverfault.com/questions/437342/how-can-i-rename-a-unix-user) from `algorand` to `algo`

@PhearZero implementation note: we should warn when we detect this, but need to take care not to confuse a service `algorand` user (uid < 1000) with a regular `algorand` user (uid >1000)

Fix patch:
diff --git a/internal/algod/linux/linux.go b/internal/algod/linux/linux.go
index ec96c154..4eb0a5f2 100644
--- a/internal/algod/linux/linux.go
+++ b/internal/algod/linux/linux.go
@@ -8,7 +8,9 @@ import (
 	"github.com/charmbracelet/log"
 	"os"
 	"os/exec"
+	"os/user"
 	"runtime"
+	"strconv"
 	"strings"
 	"text/template"
 )
@@ -24,6 +26,20 @@ type Algod struct {
 	DataDirectoryPath string
 }
 
+func hasConflictingUser() bool {
+	if runtime.GOOS != "linux" {
+		return false
+	}
+	algorandUser, _ := user.Lookup("algorand")
+	if algorandUser != nil {
+		uid, _ := strconv.Atoi(algorandUser.Uid)
+		if uid >= 1000 {
+			return true
+		}
+	}
+	return false
+}
+
 // InstallRequirements generates installation commands for "sudo" based on the detected package manager and system state.
 func InstallRequirements() system.CmdsList {
 	var cmds system.CmdsList
@@ -47,7 +63,12 @@ func InstallRequirements() system.CmdsList {
 
 // Install installs Algorand development tools or node software depending on the package manager.
 func Install() error {
+	if hasConflictingUser() {
+		return fmt.Errorf("Your system has a user called \"algorand\". The algorand node requires the \"algorand\" username for internal usage. Rename or remove the algorand user to continue.")
+	}
+
 	log.Info("Installing Algod on Linux")
+
 	// Based off of https://developer.algorand.org/docs/run-a-node/setup/install/#installation-with-a-package-manager
 	if system.CmdExists("apt-get") { // On some Debian systems we use apt-get
 		log.Info("Installing with apt-get")


Test patch: