Fork me on GitHub

Hello guys, can someone help me setting up Intellij + cursive with babashka? I can't get it to recognise dependencies. Do I have to create a dummy lein project with babashka as a dependency to make it work?


@beltramo.ale If you want auto-completion things and have Cursive analyze the dependencies then probably it's enough to add a deps.edn with the deps you are using in your script(s)


Thanks, I'll try that! How does it play with pods? I would like to use lispyclouds/docker but my guess is that (require '[pod.lispyclouds.docker :as docker]) will never be accepted by cursive because the dependency from clojure should be: [clj-docker-client.core :as docker] .


@beltramo.ale If you use the babashka nREPL server you can get auto-completions for this, but pods aren't dependencies that can easily be statically analyzed


Right, I see.. Is there a better IDE for developing babashka scripts? What do you guys use then?

Eamonn Sullivan09:02:17

I'm trying to run an nrepl (`bb --nrepl-server 1667`) with cider in emacs. This seems to work fine, usually, but this morning the repl just dies silently when I try to eval a buffer. I'm sure it's just an error in my code, but I don't get any error messages (either on the bb side, nor on the cider side). Is there a way to see what's going wrong? I tried --verbose with no result.

Eamonn Sullivan09:02:56

Ah, I see what's happening. I'm trying to eval the whole buffer, so it's running the code and spitting out a usage message (i.e., because I don't have the required args). I didn't spot that amidst the "closed unexpectedly" message from cider.


Should that cause the nrepl to crash, though?

Eamonn Sullivan15:02:17

Nah, just exit normally, with a usage. Cuz that's what I asked it to do. I rewrote the script to have a -main function and then did something like this

(when (= *file* (System/getProperty "babashka.file"))
So now I can eval the whole buffer and use the functions, but the script itself doesn't run.


Ah, makes sense


I use emacs


@beltramo.ale Developing bb scripts should not require a lot from an editor. Just paredit + syntax highlighting maybe. Bb scripts start so fast that you usually barely need a REPL, although many people do prefer one.


If IntelliJ / Cursive gives you trouble for developing a script, maybe discuss it with the author to add better support for it.


Here's the commands I made to spawn and connect to a babashka repl, from emacs/CIDER:


I meant to improve them before sharing, but never took the time. It works for me at least :man-shrugging:


Yeah I just saw the issue is that since it can't recognise imports just set everything as errors and it's unusable. I'm trying calva and it seems to do the trick. Thanks for the help, and the amazing work behind Babashka!


Calva uses both clojure-lsp and nrepl for the completions. And clojure-lsp also makes a lot of other features available. You can probably get a lot of the similar experience in Emacs using CIDER + lsp-mode. But with Calva it is out-of-the-box. Not possible to opt-out, even . 😃


“Oh no I can’t opt out of this very helpful feature”. Now that’s the kind of problems I want.


I think it's good to have opinions (defaults), but not to be stubborn: always give people a way out, unless your tool can't function without it

David Pham12:02:33

It might not be the right place, but is there any magic trick to have pprint with cider using bb --nrepl-server ?


it’s merged in now! just update your bb


@neo2551 There is an open PR for this in babashka.nrepl which is currently stalled. Maybe you could help out by reading the issue and seeing what remains to be done.


I think it's more or less done

David Pham12:02:21

Thanks! I believe you are too nice with respect to my skills!

David Pham12:02:43

But I will give a shot tomorrow.

David Pham12:02:59

Thanks for pointing me out to the solutoin.


Is the issue just the pprint-fn where with-out-str should wrap it?


as in, the only remaining one? I can’t push to his branch and it would be a shame to have to open a new PR and lose the review history just to fix that one thing. Can you push on his branch?


I can merge his PR to a branch and then you can open a new PR to that branch


I can do that


or i can open a new PR, your preference of course


if you remember, I only saw babashka yesterday, so getting set up with sci and everything might take me some time


I just wanted to encourage the PR to not die 🙂


@U01KUQRDMLG I merged to the pprint branch now. Feel free to continue with a new PR on that branch


I made a few comments in the old PR which have not been processed yet. Notable the one about *out*

👍 3
Eamonn Sullivan17:02:49

So, I finished my first moderately-sized It will probably make any competent babashka user's eyes bleed, is basically a translation of a bash script, but it was fun to do. I originally had more actual Clojure (as opposed to calls to in it, but I stripped that back after I basically wiped a PC while trying to test it. 😮 (The problem turned out to be an incorrect exclude to rsync, so I was copying over a symlink to / and when I tried to remove the directory using pure and naive Clojure, it went down that rabbit hole.) I am definitely hooked!

👍 12

@eamonn.sullivan Looks like a legit script to me! Great job and hope you have recovered from your disk erasure well