This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-26
Channels
- # aleph (9)
- # announcements (31)
- # babashka (23)
- # beginners (35)
- # biff (2)
- # calva (5)
- # cider (10)
- # clara (11)
- # clerk (114)
- # clj-kondo (18)
- # cljdoc (37)
- # clojars (7)
- # clojure (24)
- # clojure-austin (10)
- # clojure-europe (27)
- # clojure-nl (1)
- # clojure-norway (23)
- # clojure-uk (2)
- # clojurescript (18)
- # conjure (2)
- # core-async (6)
- # cursive (21)
- # datomic (3)
- # fulcro (15)
- # introduce-yourself (7)
- # lsp (32)
- # malli (57)
- # meander (5)
- # music (1)
- # nbb (2)
- # off-topic (17)
- # pathom (6)
- # rdf (4)
- # reagent (8)
- # releases (2)
- # shadow-cljs (4)
- # slack-help (23)
- # spacemacs (6)
- # tools-build (32)
;; babashka v1.1.172
(babashka.process/shell {:continue true} "fo")
;; java.io.IOException: error=2, No such file or directory..
I'm confused why it throws an err.It seems process builder throws when the program doesn't exist:
:via
[{:type java.io.IOException
:message "Cannot run program \"fo\": error=2, No such file or directory"
:at [java.lang.ProcessBuilder start "ProcessBuilder.java" 1128]}
{:type java.io.IOException
:message "error=2, No such file or directory"
:at [java.lang.ProcessImpl forkAndExec "ProcessImpl.java" -2]}]
How do you guys answer "can I shell out to a program" from babashka scripts? I want to warn users and exit early if they need to install something in order to use my script. In Go, I've used https://pkg.go.dev/os/exec#LookPath. I skimmed the API docs for babashka/process and babashka/fs, but I didn't spot what I was looking for. > LookPath searches for an executable named file in the directories named by the PATH environment variable. If file contains a slash, it is tried directly and the PATH is not consulted. Otherwise, on success, the result is an absolute path.
I suppose I could iterate over (babashka.fs/exec-paths)
.
https://github.com/babashka/fs/blob/master/API.md#babashka.fs/exec-paths
@U3X7174KS shell
should already do what you want
can shell
let me know whether there is an fzf
binary on the user's path before invoking fzf
?
(I can confirm that using shell
to invoke fzf
works perfectly when I have fzf
on my system)
Very quick and dirty hack to solve "I want to install some library I've used before, but I don't remember the coordinates".
1. Make sure you have babaskha, fzf
and bbin
installed
2. bbin install io.github.teodorlu/neil-quickadd --latest-sha
3. neil-quickadd rescan
(just need to run this once)
4. neil-quickadd
5. Pick a library
6. neil dep add
is executed to add the library.
Only works for ZSH for now. And there's very little validation. But it's 80 lines total -- all the heavy lifting is done by bbin, babashka/fs, babashka/process and babashka/neil. This works by parsing ~/.zsh_history
, which may be a bad idea.
@U3X7174KS https://github.com/ThaddeusJiang/chr is another tool that parses shell history (zsh and bash), maybe it helps to make it more portable :)
Thanks! I know for a fact that I don't handle multiline shell commands correctly right now.
Would it be valuable to have paths from the https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html in babashka/fs? E.g. (fs/xdg-config-home) ;;=> #object[sun.nio.fs.UnixPath 0x3c79d6e5 "/Users/gert/.config"]
(as well as fs/xdg-data-home
, fs/xdg-cache-home
and fs/xdg-state-home
).