Fork me on GitHub
#babashka
<
2024-02-21
>
reefersleep12:02:31

I'm trying to work with bb and Conjure in a project that I know to be working (it runs in our CI 🙂 ) When I try to evaluate a namespace that requires e.g. medley.core, the Conjure repl tells me that it does not know that ns. Do I need to run some bb command to "install" dependencies?

emilaasa13:02:08

Do you have medley on the classpath?

emilaasa13:02:20

Adapting this example to Conjure: https://github.com/babashka/babashka/blob/master/doc/projects.md#medley

$ export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {medley/medley {:mvn/version "1.3.0"}}}')
vim somescript.clj
(require '[medley.core :as m]) 

(m/index-by :id [{:id 1} {:id 2}])
; => {1 {:id 1}, 2 {:id 2}}

reefersleep13:02:47

it's in bb.edn

:deps           {dev.weavejester/medley {:mvn/version "1.7.0"}
...

emilaasa13:02:54

I'll try that as well, sec.

emilaasa13:02:59

Should work I think..

emilaasa13:02:17

Yeah works for me

emilaasa13:02:30

{:deps  {dev.weavejester/medley {:mvn/version "1.7.0"}}}

reefersleep13:02:36

I re-checked and it works for me, now, too! wtf!

reefersleep13:02:51

Maybe the folder that I open nvim from is important?

emilaasa13:02:52

Maybe the cp was overwritten somehow

emilaasa13:02:58

Yes that is key 🙂

reefersleep13:02:59

because that's the only thing that changed AFAIK

emilaasa13:02:14

It probably runs bb in that dir

reefersleep13:02:31

thank you so much!

emilaasa13:02:06

It works insanely well now with Conjure and bb when you get used to the quirks

emilaasa13:02:10

Being able to open any file and just start evaluating stuff is great

reefersleep13:02:34

Which quirks have you stumbled particularly upon?

emilaasa13:02:22

It's mostly about my own shell env and which folder I'm in

emilaasa13:02:45

Like wondering why it doesn't work when I'm actually connected to my normal JVM repl 🙂

emilaasa13:02:16

The docs are way better than my ability to read them though!

reefersleep13:02:38

for most docs 😛

reefersleep13:02:32

Does

<localleader>gd          Go to the definition of the word under the cursor.
                         Support for this may vary between languages.
work for you? I get an error about an unsupported target.

emilaasa14:02:12

Yes it works for me

emilaasa14:02:18

Have you evaluated the buffer?

emilaasa14:02:39

; def (word): m/index-by
; zipfile:///home/aasa/.m2/repository/dev/weavejester/medley/1.7.0/medley-1.7.0.jar::medley/core.cljc [293 1]

reefersleep10:02:07

Yeah ok, it works for functions defined within the same buffer, but not for functions from a different buffer unless I've eval'ed that buffer. It also does not work for e.g. function parameters used in the function body, which I thought a fair assumption, but an assumption, none the less 🙂

reefersleep10:02:35

Thanks for checking/elaborating 🙂

emilaasa13:02:47

Thanks BORKDUDE, I rewrote some more bash scripts into glorious bb today and could not have been happier with the experience.

❤️ 5
pavlosmelissinos16:02:02

Hello! Can someone help me translate this curl request to its equivalent with babashka/http-client please?

curl -X POST -d @/path/to/file.json \
  -H "Content-Type: application/json" \
  --url my-url \
  --header 'authorization: Bearer REDACTED-JWT-TOKEN'
So far I have this:
(http/post "my-url"
             {:headers {"Content-Type" "application/json"
                        "Authorization" "Bearer REDACTED-JWT-TOKEN"}
              :data (slurp "/path/to/file.json")})
But I'm getting errors from the server, while the curl variant works and I'm not sure what's the issue. is it the file? I'm not sure what babashka expects PS: (shower thought) are you aware of any tools that convert curl commands to clj-http/babashka http-client inputs and vice versa? :thinking_face:

2
Wanishing17:02:53

What are the errors you get?

Wanishing17:02:39

It will help narrow down the issue

mmer17:02:13

Should the :data option be :body? Just a thought..

1
pavlosmelissinos18:02:05

The error isn't informative, it's a generic flask message about an invalid request. I'm not at my computer right now but I'll check tomorrow Damn, could be data vs body. Thanks for the hint

borkdude10:02:52

Seems like this issue is solved then?

👍 1
pavlosmelissinos12:02:06

It should be body indeed facepalm - still doesn't work but doesn't seem to be babashka-related (emacs hangs) Thanks, I was starting to lose my mind 😄

mmer13:02:52

I don't know if this would help, but the use of the Client within the bb implementation helped me get over insecure server issue.

1
respatialized22:02:00

can I access *input* from inside a task?

borkdude22:02:37

I don't recommend using *input* outside of command line one-liners, just use slurp + *in*

✔️ 1