Fork me on GitHub
#babashka
<
2021-09-18
>
mike_ananev20:09:46

Is there any way to set default ns in Babashka preloads? I have preloads.clj file loaded via (load-file) and I want to run bb '(foo)' instead of bb '(preloads/foo)'

mike_ananev20:09:51

I found workaround export BABASHKA_PRELOADS=cat preloads.clj`` but removed (ns preloads) in the begining of the file

borkdude20:09:52

yeah, that is the correct workaround, just define your functions in the user namespace

mike_ananev21:09:05

With babashka I started to forget linux commands and their complex parameters. I think about to create preloads.clj file with common functions like: ls, grep, find, etc., but with clojure syntax and more simple parameters. Is there any examples of such preloads files with a bunch of every day functions?

borkdude21:09:24

@mike1452 That's a great idea. I'm not aware of anyone who did this yet.

mike_ananev21:09:59

I need a hammock time. ๐Ÿ˜›babashka

mike_ananev21:09:35

First function:

(defn whoami
  []
  (System/getProperty "user.name"))
๐Ÿ˜‚

๐ŸŽ‰ 2
Leah Neukirchen21:09:58

Am I doing this wrong or doesn't this library work with bb?

rhea ~mess%ย cat bb.edn
{:deps {fr.jeremyschoffen/prose-alpha {:mvn/version "30"}}}
rhea ~mess%ย bb -e "(require '[fr.jeremyschoffen.prose.alpha.reader.core :as reader])"
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Could not resolve symbol: *clojure-version*
Location: clojure/tools/reader/impl/utils.clj:17:35

borkdude21:09:32

That's one of the issues. I don't know what this project uses. Co-incidentally, it does offer ability to run within SCI so you could compile your own graalvm binary which can run this stuff

Leah Neukirchen21:09:12

note that the code is pulled in from clojure.tools

borkdude21:09:10

clojure.tools.?

Leah Neukirchen21:09:29

hmhm, then it goes on with

java.lang.Exception: Unable to resolve classname: java.io.Closeable [at clojure/tools/reader/reader_types.clj:14:3]

Leah Neukirchen21:09:54

i'll try the other way then

borkdude21:09:40

we can add Closeable for sure, but probably not support tools.reader from source right now. I see it also uses instaparse which is also complicated probably

Leah Neukirchen21:09:19

i thought clojure.tools.reader was more core than it is, it's fine ๐Ÿ™‚

borkdude21:09:21

oh it probably loads clojure.tools.reader because it loads sci :)

borkdude21:09:46

and sci definitely cannot run itself right now ;)

clojure-spin 1