Repository: sebadob/rauthy (language: rust)

Issue:
`just setup` installs `just`
Before getting into the issue: Thanks for creating this project!

 I was starting to test it and tried to build it and noticed `just setup` was configured to install just. This seemed unnecessary to me - If you can run `just setup`, just is already installed.

Is there a reason for this that I am missing or is this something that could be cleaned up?


---

Edit: I noticed it calls `command -v` first. For some reason, that did not pick up just on my system, even though it was clearly installed. I'll check if I can figure out the reason for that. Still, even with the check, it seems unnecessary to perform that check.


Discussion / hints:
> Is there a reason for this that I am missing or is this something that could be cleaned up?

You're right, this can be cleaned up, absolutely. This might be a left-over from when the setup has been in a dedicated bash script before the integration into the `justfile`. The `command -v` checks could even be removed as well. If the installed version is the latest one, nothing will happen anyway and if there is a newer one, it will be installed. Without the `command -v` check, multiple runs of `just setup` could also be used to keep the tooling up-to-date.

Fix patch:
diff --git a/justfile b/justfile
index 35f87870c..badb73bc7 100644
--- a/justfile
+++ b/justfile
@@ -29,11 +29,11 @@ setup:
     set -euxo pipefail
     clear
 
-    echo "Installing necessary tools: just, sd, mdbook, mdbook-admonish, sqlx-cli"
+    echo "Installing necessary tools: sd, mdbook, mdbook-admonish, sqlx-cli"
     readarray -t cargopkgs < <(cargo install --list | cut -d' ' -f1 | sort | uniq)
-    for pkg in just sd mdbook mdbook-admonish; do
+    for pkg in sd mdbook mdbook-admonish; do
         if command -v "$pkg" &>/dev/null; then
-            if printf '%s\0' "${cargopkgs[@]}" | grep -qw "$pkg"; then
+            if ! printf '%s\0' "${cargopkgs[@]}" | grep -qw "$pkg"; then
                 cargo install "$pkg"
             fi
         else
@@ -41,7 +41,7 @@ setup:
         fi
     done
     if command -v sqlx &>/dev/null; then
-        if printf '%s\0' "${cargopkgs[@]}" | grep -qw sqlx-cli; then
+        if ! printf '%s\0' "${cargopkgs[@]}" | grep -qw sqlx-cli; then
             cargo install sqlx-cli --no-default-features --features rustls,sqlite,postgres
         fi
     else


Test patch: