From 9aa1479d815b31ab0b9226a0bac4cd4cace16998 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Thu, 11 Jun 2026 21:10:10 -0400 Subject: [PATCH] deps: jolt-deps finds the jolt binary next to itself MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Running a checkout's build/jolt-deps by path failed with ENOENT unless build/ was also on PATH: exec-jolt spawned a bare "jolt". Resolution is now $JOLT_BIN, then the jolt sitting beside this binary (argv[0]'s directory — the pair is built together), then PATH. --- src/jolt/deps_cli.janet | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/jolt/deps_cli.janet b/src/jolt/deps_cli.janet index 28d9834..0da62fa 100644 --- a/src/jolt/deps_cli.janet +++ b/src/jolt/deps_cli.janet @@ -34,13 +34,28 @@ (defn- roots [aliases] (if (os/stat "deps.edn") (deps/resolve-deps-cached "deps.edn" nil aliases) @[])) +(defn- jolt-bin + "The jolt executable: $JOLT_BIN, else the `jolt` sitting NEXT TO this + jolt-deps binary (the pair is built together — running a checkout's + build/jolt-deps by path must not pick up some other jolt, or fail when + none is on PATH), else `jolt` from PATH." + [] + (or (os/getenv "JOLT_BIN") + (let [self (or (first (dyn :args)) (dyn :executable)) + slashes (when self (string/find-all "/" self)) + dir (when (and slashes (> (length slashes) 0)) + (string/slice self 0 (last slashes))) + sibling (when dir (string dir "/jolt"))] + (when (and sibling (os/stat sibling)) sibling)) + "jolt")) + (defn- exec-jolt [aliases extra-args] # Set JOLT_PATH in our own env and let the child inherit it (os/execute's env # arg isn't honored here; inheriting is reliable). (def rs (string/join (roots aliases) ":")) (def existing (os/getenv "JOLT_PATH")) (os/setenv "JOLT_PATH" (if (and existing (> (length existing) 0)) (string rs ":" existing) rs)) - (os/execute [(os/getenv "JOLT_BIN" "jolt") ;extra-args] :p)) + (os/execute [(jolt-bin) ;extra-args] :p)) (defn- usage [] (print "usage: jolt-deps [-A:alias[:alias]] [path | run FILE [args] | repl | -e EXPR [args]]")