This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-09
Channels
- # announcements (3)
- # babashka (17)
- # beginners (75)
- # calva (43)
- # cider (1)
- # clj-kondo (54)
- # cljdoc (8)
- # cljs-dev (70)
- # clojure (83)
- # clojure-europe (27)
- # clojure-nl (4)
- # clojure-norway (4)
- # clojure-spec (8)
- # clojure-uk (13)
- # clojured (2)
- # clojurescript (47)
- # community-development (4)
- # conjure (2)
- # cursive (3)
- # datomic (5)
- # emacs (5)
- # events (3)
- # fulcro (13)
- # graalvm-mobile (19)
- # helix (2)
- # introduce-yourself (1)
- # jobs (2)
- # jobs-discuss (28)
- # kaocha (9)
- # livestream (11)
- # malli (15)
- # meander (24)
- # nextjournal (8)
- # off-topic (26)
- # pathom (1)
- # pedestal (8)
- # polylith (2)
- # portal (31)
- # re-frame (4)
- # reagent (10)
- # reitit (8)
- # remote-jobs (3)
- # sci (1)
- # shadow-cljs (66)
- # spacemacs (20)
- # testing (6)
- # vim (15)
- # xtdb (7)
Is there a way to run part of my project as a babashka script?
The only examples that I found in the repository are the ones that either import some kind of a library or are self-contained in the source file. What if I have many sources and I want to run it from sources?
Edit: I found the bb --init
but it's not enough because I have quite a bit of sources. Is there a way to form the "classpath-loadpath" automatically?
(also I use leiningen for the project and I'm not familiar with edn format)
@U028ART884X You can use bb -m foo.bar/baz
to execute a function if foo/bar.clj
is on your classpath
Classpath... does it need to be specified in edn
? Because my project is in leiningen. Probably that's a problem.
Ok. I'll try it. But I think I have some libraries that babashka won't run. But I want to firstly run something. Thanks.
lein classpath
spits the classpath to a file - there is a way to wiggle that in to one command i’m sure
What you can also do if you want to use libraries that are brought in by leiningen:
lein classpath > .classpath
bb -cp $(cat .classpath) -m foo.bar/baz
It worked. Now I have to decide what to do with all of it...
Type: java.lang.Exception
Message: Could not find namespace: java-time.
@U028ART884X It seems the classpath wasn't set properly, else you would see a different error, now it just can't find the java-time namespace since it's not on the classpath
No, my project is internal to the company. But well. I've successfully hit a snag 😄 :
Type: java.lang.Exception
Message: Unable to resolve classname: java.lang.reflect.Field
Location: java_time/util.clj:3:3
But the trick with leiningen classpath
worked really well. Thanks.nice. yeah, this class isn't available in bb (yet). The java.time
package is, so if you can avoid this library maybe that would help.
It's not important, I think. I think that I import too much where I could split my namespaces.
OK. I think I was almost there, but java-time uses deftype
which is one thing that bb can't handle (yet).
https://github.com/dm3/clojure.java-time/blob/f9e11c3f852c14adf579d5101e7e98ec198eb343/src/java_time/properties.clj#L19-L31
If those would be records, then it would run.
There are a couple of other java.time clojure libraries that do work with babashka, e.g. cljc-time
Thanks. I don't want to push anybody into doing anything. I wanted to also try out the script runner. I'll try that time lib if I'll need time.