Fork me on GitHub
#babashka
<
2023-05-08
>
mlierren02:05:30

Hello. I have a question. In fact, I have a very frustrating task at the company. I need to develop a script on Windows server 2012 in a closed network. The task to be developed is “create a csv file after extracting data from the mssql server with a select statement and simple data processing”. What makes me hard • windows server 2012, • It is a server in a closed network that is not connected to the Internet. Files necessary for development can be transferred to the server via USB. Can I use babashka to do what I want? Can you suggest a development setup suitable for this situation?

borkdude05:05:57

Yes, it’s possible to use bb for this. I’ll reply with more details later today.

🙏 2
borkdude08:05:50

So, do you need to connect to mssql from bb?

borkdude08:05:16

Or is that only "after extracting data from mssql"?

borkdude08:05:42

You can connect to mssql with a sql pod: https://github.com/babashka/babashka-sql-pods#ms-sql-server-support You can download the pod separately and load it with (babashka.pods/load-pod "<path-to-pod>") and then execute the above code. Another way involves maybe shelling out to https://learn.microsoft.com/en-us/sql/tools/mssql-cli?view=sql-server-ver16 or so. For csv you can use clojure.data.csv which is built into bb.

👍 2
2
mlierren09:05:55

Your guidance is enough for me to do the task. Thank you so much for your kind guidance. 🙂

👍 2
Casey10:05:06

I have the following line in my ~/.config/clojure/deps.edn to prevent jars from being installed in ~/.m2: :mvn/local-repo "/home/ramblurr/.cache/maven/repository" When I use clojure .... this is respected, but when I call clojure via bb it isn't.. For example with repl-portal (shell "clojure -A:dev -M:inspect/portal-cli-cider") as a task in a project's bb.edn running bb repl-portal will download lots of jars into ~/.m2

borkdude11:05:40

This should work the same way, you're just shelling out to clojure. But it could be that you're having some :deps in bb.edn itself which are downloaded?

borkdude11:05:46

Yes, this:

:deps {local/deps {:local/root "."}}
is causing the dependencies in your deps.edn to be downloaded as well

borkdude11:05:22

Btw, don't use the name local/deps: use a unique name there since if you use the name local/deps in other places, you'll get caching problems

Casey11:05:18

hmm ok don't remember how that ended up there in the first place, probably copied it from another project. removing it seems to solve the problem. thanks!

rads15:05:06

Ah, I didn't know about this either. The local/deps solution was originally in the docs but it looks like this was changed a few months ago: https://github.com/babashka/book/commit/b88e3646bb726ed16f2799986f4603719784bee3 bbin is actually generating scripts that use local/deps at the moment so that sounds like a bug we'll want to fix

borkdude15:05:41

@U0CLCL6T0 yeah, please fix :)

👍 4
pesterhazy12:05:45

We (=Pitch) have taken over as maintainers of asdf-babashka, whose excellent author hasn't been responsive in 2yrs. Our fork (which fixes an important issue on Apple Silicon) is maintained here: https://github.com/pitch-io/asdf-babashka We're also taking steps to get this published as the official asdf babashka plugin

🎉 12
💯 2
❤️ 2
pesterhazy12:05:15

Feel free to ping us here if you have any questions (we love asdf!)

joakimen13:05:22

It's almost embarrassing how the "main" babashka-plugin has been broken since M1 came out, should have been replaced with your fork much sooner. FWIW, I highly recommend checking out https://github.com/jdxcode/rtx. Without evangelising too much, it's better in almost every regard, piggybacking on the asdf plugin repo, and respects .tool-version files for converts.

thanks2 2
pesterhazy13:05:19

Right, we're also investigating rtx as an alternative. ASDF works very well, but it has one flaw – it adds up to 400ms to every invocation of java, clojure, bb etc. This can add up. A couple of possible fixes for this: • Switch to rtx • Build a PATH https://github.com/asdf-vm/asdf/issues/290 • Use https://github.com/asdf-community/asdf-direnv

pesterhazy13:05:11

I feel like betting on rtx is a little risky now (as asdf has a bigger community), but I agree that rtx has the better design

pesterhazy13:05:20

(Another problem with asdf's shims, other than performance, is that they are on the PATH even if you don't have a .tools-version. It wants to own the world. AFAIK rtx with its PATH-modifying approach doesn't have that problem)

jmglov05:05:38

Speaking of things that are worse than Nix (troll) I need to get around to opening a PR for my Nix derivation that pulls the pre-built binary version of Babashka, and then convince the powers that be at Pitch (whoever they might be) to maintain that. 😜

ag23:05:48

Does anyone know why my bb script in CIDER sometimes doesn't want to execute (cider-pprint-eval-last-sexp) and would throw "java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number"?

borkdude07:05:41

Doesn’t ring a bell. Need more info, repro

ag14:05:41

Ah, maybe it's not a problem with bb. Something to do with cider-nrepl. My minimal setup with deps.edn project and I'm seeing the same thing:

Error printing return value (ClassCastException) at clojure.lang.Numbers/lt (Numbers.java:253).
class clojure.lang.PersistentVector cannot be cast to class java.lang.Number (clojure.lang.PersistentVector is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
ERROR: Unhandled REPL handler exception processing message {:op analyze-last-stacktrace, :nrepl.middleware.print/stream? 1, :nrepl.middleware.print/print cider.nrepl.pprint/pprint, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/buffer-size 4096, :nrepl.middleware.print/options {:right-margin 70, :length []}, :session f7cb9ce8-09b8-4c25-8d2f-b8fadd762169, :id 14}
java.lang.ClassCastException: class clojure.lang.PersistentVector cannot be cast to class java.lang.Number (clojure.lang.PersistentVector is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')

borkdude14:05:10

:length []?

ag14:05:27

yeah, it seems CIDER not sending the right thing, not sure how that broke in my setup.

borkdude14:05:59

Maybe it's in your elisp somewhere? not sure, but good to know it's not a bb problem

ag15:05:11

Yup, turns out I messed up my cider-print-options and didn't notice. It coincided with the time when I started debugging a bb script. Apologies for the noise.

👍 1