This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # babashka (23)
- # beginners (65)
- # calva (126)
- # cider (23)
- # clj-kondo (10)
- # clojure (41)
- # clojure-europe (5)
- # clojure-nl (2)
- # clojure-uk (6)
- # clojurescript (78)
- # contributions-welcome (1)
- # crux (4)
- # datomic (9)
- # events (1)
- # graalvm (2)
- # meander (10)
- # off-topic (81)
- # pathom (5)
- # shadow-cljs (3)
- # spacemacs (6)
- # vim (3)
Hi, complete newby here. I've decided to explore this one whole babashka thing that I hear so many great things about. I'm a (maybe) advanced beginner (at best) on Clojure and I'm going to try this afternoon to rewrite my very crufty bash backup script into something more fun to maintain and change. But what do you people use for tooling? I tried to create a backup.clj file in emacs and my Clojure set up kicked in, with clojure-lsp complaining about the 35,000+ files in this "project" (i.e., my home directory). I then tried to use
clojure -X:new ... to create a simple small deps.edn project to work in, so I'd get all the niceness of CIDER, but the syntax is a bit different, isn't it, for things like imports and requires. How do people generally write these? Do you write them first in Clojure (or ClojureScript) and then make the last-minute adjustments?
@eamonn.sullivan The simplest way to get started is just write a
script.clj with a shebang or just execute it with
OK, so I just be mostly OK working in Clojure (to use Cider and LSP) and then adding the shebang at the end, to make it stand-alone?
Yes, I got that far fairly quickly from the examples. And I got it kind of working in a short period of time. What I'm running into is that when I open the bb script in Emacs to edit it, my configuration gets confused. I have so many things set up to start when the extension in the buffer ends in *.clj, and those don't expect to work with a shell script. Clojure-lsp is trying to find the project definition, for example.
I think that might be good to mention in the #lsp channel. LSP should support scripts. You can write standalone scripts in JVM clojure too. cc @ericdallo
I think @pez also asked about this once (he is the originating author of Calva, which is now also using clojure-lsp)
@eamonn.sullivan Just clojure-mode and clj-kondo should be good enough for babashka, for small scripts. Babashka also supports a REPL, but for small scripts I find it sufficient to just run it from the terminal each time
Something has changed in clojure-lsp since I asked about that. Now it just works. I have code navigation, documentation lookup, outline, clj-kondo linting, … the lot, when opening my babashka scripts, even though they have shebangs. I start bb with the
--nrepl-server and enjoy the REPL workflow I am used to after connecting Calva. At the end of some “entry” scripts I have check if it is running as a script or in the repl. That is mainly so that loading the file in the REPL is a way to perform some basic smoke testing.
It is so sweet I have a hard time fathoming it. Maybe babashka is about to position itself as Clojure’s killer app? It is hard to see who, in their right mind, and after some carefully designed introduction, would choose to script in anything but babashka.
Yeah, I literally just discovered (from the aforementioned manual)
bb --nrepl-server and now have a full cider/lsp experience. Very nice! Thanks again for this. I might never write another bash script.
Cool, this should work with lsp indeed, we support both project and single file clojure code, any issues LMK in #lsp :)
Hi, all, a question: I'm writing my first babashka script and I'd like to write some tests for it. I think I've followed the instructions in the babashka book about my project structure/test_runner, but I'm getting a strange error when I try to redefine a function in the script using with-redefs:
clojure.lang.ExceptionInfo: Method format on class sci.impl.fns$fun$arity_0__16223 not allowed! . My repo is here: https://github.com/eamonnsullivan/backup-scripts. I'm just trying to write my first, simple test around date handling before I tackle some of the harder ones. Can anyone spot my simple mistake?
@eamonn.sullivan The reason you are getting this error is that you are re-defining date as a function in your tests, while in your normal code it's a date, not a function
Added lots of functions to babashka.fs today. You can already use this lib as a git lib and it's built into bb in the
fs branch (see #babashka_circleci_builds or visit the builds via Github).
I want to wait on some feedback for a while before it will end up in babashka. Please test and review!
API docs: https://babashka.org/fs/