Fork me on GitHub
#babashka
<
2020-05-18
>
Michael W02:05:21

how can I see the current classpath from the repl?

kolharsam03:05:27

One thing you can perhaps do is that you can read the BABASHKA_CLASSPATH like so (System/getenv "BABASHKA_CLASSPATH") if the classpath is already set prior to running the REPL.

kolharsam03:05:56

bb also has a ns basbashka.classpath which you can use add to the current ns https://github.com/borkdude/babashka#babashkaclasspath

Michael W15:05:01

Thanks, and I looked at those, and tried to add a jar both using the env and add-classpath but I still can't import the library. Just trying to get rebel-readline working for a better repl experience. I was hoping to look at the classpath babashka sees so I could compare it to what I was expecting.

borkdude15:05:41

What does "can't import the library" mean? Do you get an error, or what?

Michael W15:05:53

Yes it says it can't find it.

borkdude15:05:37

how did you contruct BABASHKA_CLASSPATH, what's the value of that?

Michael W15:05:42

[Mon May 18][08:57:35][[email protected]][~/.m2/repository/com/bhauman/rebel-readline/0.1.4] $ BABASHKA_CLASSPATH=/home/mwhitford/.m2/repository/com/bhauman/rebel-readline/0.1.4/rebel-readline-0.1.4.jar bb

Michael W15:05:10

user=> (require 'rebel-readline) clojure.lang.ExceptionInfo: Could not require rebel-readline. [at line 1, column 1]

borkdude16:05:27

shouldn't it be something like (require 'rebel-readline.core)?

borkdude16:05:43

user=> (require 'rebel-readline.core)
clojure.lang.ExceptionInfo: Unable to resolve classname: org.jline.reader.UserInterruptException [at rebel_readline/core.clj, line , column ]

borkdude16:05:55

so the classpath is correct, your namespace in require was wrong

borkdude16:05:18

and unfortunately, this does library does not work with bb as you can see.

borkdude16:05:35

but you can always use --nrepl-server and connect from your favorite editor. much better than typing in a REPL

Michael W16:05:36

thanks anyways, I'll just use clojure directly

dabrazhe07:05:13

Hi. How has babashka name come to be, what's the history?

borkdude08:05:30

@dennisa It's a play on words with bash. Bash is old. Babushka means granny in Russian but also the scarve a granny wears. Babushka is also used as a synonym for matryoshka which is a nested doll, which hints at a Clojure interpreter built in Clojure itself.

borkdude08:05:18

But ultimately it just sounds cool.

💯 1
dabrazhe09:05:08

Thanks : ) I can't help noticing that these two statements are not really true : ) "Babushka means granny in Russian but also the scarve a granny wears. Babushka is also used as a synonym for matryoshka which is a nested doll,"

dabrazhe09:05:31

The scarf is schal (like sjal in dutch) or platok. Matrёshka is a dimunitive for a younger girl and one would not call a old woman like that normally

borkdude09:05:27

I didn't say people use matryoshka for old woman, but mistakingly for the nested doll.

borkdude09:05:45

So you are confusing these two. Babushka -> old woman, headscarve. Babushka -> mistake synonym for matryoshka = nested doll = Clojure in Clojure.

dabrazhe09:05:47

"also known as Babushka dolls" -- this is weird, perhaps a a western marketing term, but never used in Russian.

borkdude09:05:31

Yeah, that might be. Babushka has become a fashion word for headscarves in the west, associated with old women, but now also worn by fashionable girls

borkdude09:05:10

If you really want to get to the bottom of it: babashka itself also means a bar used in typography to mark connection between words. In Russian. It's true, look it up 😉

dabrazhe09:05:20

"Babushka has become a fashion word for headscarves" I guess you are close here, it's another marketing term but more correct would be 'babushka's head scarf' (platók)

borkdude09:05:38

Thanks for clarifying

dabrazhe09:05:21

cool, the word actually exists! I learned smth today 🙂 thanks!

Babaska. 
white space with a length of 48 points with a size of 24 , 36 and 58 points . Babashki used during manufacturing of typesetting of printed forms way high print for educational non-printing areas are relatively small space in the table

borkdude09:05:30

Yeah. I had trouble finding good dictionary entries though. If you have Russian dictionaries, more details are welcome.

borkdude09:05:10

The synonym is a mistake that people often make, it's not the correct synonym, I'm aware of that. What's not true about the first statement?

dabrazhe10:05:55

How can compare current time > 15:00 in bb using eg (def now (java.time.ZonedDateTime/now)) or similar?

borkdude10:05:16

yeah, using the java.time API

mbjarland12:05:10

I have a question, I was trying to build the v0.0.96 tag (need a custom build for a target environment, the pre-built binaries will not work there) and receiving the following build error:

~> script/uberjar
...
Compiling babashka.impl.csv
Compiling babashka.impl.curl
Syntax error macroexpanding at (curl.clj:1:1).
Execution error (FileNotFoundException) at babashka.impl.curl/loading (curl.clj:1).
Could not locate babashka/curl__init.class, babashka/curl.clj or babashka/curl.cljc on classpath.

Full report at:
/tmp/clojure-6330374768462098454.edn
Compilation failed: Subprocess failed
Uberjar aborting because jar failed: Compilation failed: Subprocess failed
Error encountered performing task 'do' with profile(s): 'base,system,user,provided,dev,uberjar,xml,yaml,core-async,csv,transit'
Uberjar aborting because jar failed: Compilation failed: Subprocess failed
I was able to build previous versions without issues. Did something in the build process change?

mbjarland12:05:32

building with graal 20.0.0.r8

borkdude12:05:39

@mbjarland Did you pull babashka's submodules?

mbjarland12:05:56

yes I did a git submodules update --recursive

mbjarland12:05:24

if that counts

borkdude12:05:26

and the submodule is there in babashka.curl?

mbjarland12:05:42

hmm..now that you mention it it is empty, there is only a src dir. I am sitting on the v0.0.96 tag, i.e. not on a branch etc. Is there something else I should be doing?

mbjarland12:05:55

╭─[email protected] ~/projects/clojure/babashka  ‹(v0.0.96)› 
╰─➤ git st
HEAD detached at v0.0.96
nothing to commit, working tree clean
╭─[email protected] ~/projects/clojure/babashka  ‹(v0.0.96)› 
╰─➤ git submodule update --recursive
╭─[email protected] ~/projects/clojure/babashka  ‹(v0.0.96)› 
╰─➤ ls -al babashka.curl/src 
total 0
drwxrwxr-x 2 mbjarland mbjarland  6 May 18 13:44 .
drwxrwxr-x 3 mbjarland mbjarland 17 May 18 13:44 ..
╭─[email protected] ~/projects/clojure/babashka  ‹(v0.0.96)› 
╰─➤       

mbjarland12:05:16

probably me missing something really fundamental here

mbjarland12:05:26

I can re-clone

borkdude12:05:45

fwiw, I did this in a tmp dir:

$ git clone [email protected]:borkdude/babashka.git --recursive
$ cd babashka
$ git checkout v0.0.96
$ ls babashka.curl
CHANGES.md LICENSE    README.md  deps.edn   src        test

mbjarland12:05:48

ok git submodule weirdness, did this:

╭─[email protected] ~/projects/clojure/babashka  ‹(v0.0.96)› 
╰─➤ rm -rf babashka.curl                                                                                            1 ↵
╭─[email protected] ~/projects/clojure/babashka  ‹(v0.0.96)*› 
╰─➤ git submodule update --init babashka.curl
Cloning into '/home/mbjarland/projects/clojure/babashka/babashka.curl'...
Submodule path 'babashka.curl': checked out '82a6571d51abee402e0b40be984420000fe1c08b'
╭─[email protected] ~/projects/clojure/babashka  ‹(v0.0.96)› 
╰─➤ ls -al babashka.curl/src 
total 0
drwxrwxr-x 3 mbjarland mbjarland  22 May 18 14:46 .
drwxrwxr-x 5 mbjarland mbjarland 140 May 18 14:46 ..
drwxrwxr-x 2 mbjarland mbjarland  22 May 18 14:46 babashka
╭─[email protected] ~/projects/clojure/babashka  ‹(v0.0.96)› 
╰─➤ 

mbjarland12:05:15

now it's there

mbjarland12:05:35

so never mind, guess my submodules were not initialized for some reason

borkdude12:05:07

maybe eventually we'll get rid of the submodules, but for now it's convenient since sci and the other submodules are still in flux

mbjarland12:05:08

thanks for the help, should have figured this one out myself. While I'm at it, the tag v0.0.96 builds the following jar file:

Created .../babashka/target/babashka-0.0.97-SNAPSHOT.jar
should I be building something different to get the 96 binary?

borkdude12:05:48

I think I mistagged it by accident. there were already two new commits on master when I pushed the release button

borkdude12:05:13

the released binaries do have the correct version though

mbjarland12:05:23

ok no worries, I can check out the correct sha

mbjarland12:05:27

thanks again

borkdude12:05:35

sorry for the confusion 🙂

mbjarland13:05:42

as a side note, I did eventually get the oracle driver working as a bb feature, but it behaved really strangely with jdbc.next/graal (not allowed to close connections etc) so I've abandoned that track at least for now.

mbjarland13:05:10

maybe I'll try making a pod out of it

jeroenvandijk13:05:36

I think i’m missing something, but how should I use https://github.com/babashka/babashka.nrepl? I was thinking of building a bb script within a repl session

mbjarland13:05:27

@borkdude one last qustion, I'm often sitting and developing my bb scripts in a jvm clojure repl (intellij/cursive etc) and I would like to conditionally run some forms if the code is run in a jvm repl vs executed using bb. Currently I'm doing things like:

(if (resolve `*input*) in-bb in-jvm-repl) 
this makes me feel slightly dirty and I figured you might have a more supported way of doing this?

borkdude13:05:15

@mbjarland that would be the way I think. another way is looking at a system property that is babashka specific. or just don't use *input* in anything other than a one-liner.

mbjarland13:05:06

might be worth binding an explicit var just for this purpose? Something like *launched-with-babashka*

borkdude13:05:03

@mbjarland I'm favoring system properties instead of custom vars, since that works better with linters like clj-kondo as well and doesn't make the script Clojure-incompatible

borkdude13:05:16

There's already one called babashka.main

mbjarland13:05:00

I saw that one, tried to use it but it seemed to be nil in my test:

─➤ bb
Babashka v0.0.96 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (System/getProperty "babashka.main")
nil

borkdude13:05:28

that's because you didn't set main with -m

mbjarland13:05:05

ah, ok so it's conditionally set. I figured it might be useful to have a property which you always know is set if you are in a babashka context

borkdude13:05:53

@mbjarland yes and my proposal was a system property instead of a custom var

borkdude13:05:33

but just using resolve on babashka.classpath/add-classpath or using a reader conditional #?(:bb true) also works