Fork me on GitHub
#babashka
<
2023-06-27
>
Colin (fosskers)04:06:04

Seems like the output of fs/list-dir can't be fed to shell's dir argument? And UnixPath also doesn't seem to exist in the Java docs...

rads04:06:29

UnixPath is a platform-specific implementation of java.nio.file.Path : https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Path.html

Colin (fosskers)04:06:28

Thanks! A good ol' .toString fixed the problem for now

👍 2
borkdude06:06:00

just call str on it

borkdude06:06:25

feel free to post an issue about the first thing

Colin (fosskers)07:06:53

str also does the trick and is a bit cleaner, thanks

craftybones06:06:21

Facing a problem with babashka v1.3.179

craftybones06:06:57

With a simple bb.edn

craftybones06:06:00

{:deps {io.github.babashka/sci.nrepl {:git/url ""
                                      :git/sha "2f8a9ed2d39a1b09d2b4d34d95494b56468f4a23"}}
}

craftybones06:06:18

Running any bb command, bb tasks for ex gets the following error

craftybones06:06:32

Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
Exception in thread "main" java.io.FileNotFoundException: /Users/nitinsharma/.clojure/.cpcache/81DABDD7A1785F8709441C9E4D357137.cp (No such file or directory)
    at [email protected]/java.io.FileInputStream.open0(FileInputStream.java)
    at [email protected]/java.io.FileInputStream.open(FileInputStream.java:219)
    at [email protected]/java.io.FileInputStream.<init>(FileInputStream.java:158)
    at $fn__11617.invokeStatic(io.clj:229)
    at $fn__11617.invoke(io.clj:229)
    at $fn__11569$G__11523__11576.invoke(io.clj:69)
    at $fn__11591.invokeStatic(io.clj:165)
    at $fn__11591.invoke(io.clj:165)
    at $fn__11530$G__11519__11537.invoke(io.clj:69)
    at $reader.invokeStatic(io.clj:102)
    at $reader.doInvoke(io.clj:86)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at clojure.lang.AFn.applyToHelper(AFn.java:154)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invokeStatic(core.clj:669)
    at clojure.core$slurp.invokeStatic(core.clj:7009)
    at clojure.core$slurp.doInvoke(core.clj:7009)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at borkdude.deps$_main.invokeStatic(deps.clj:816)
    at borkdude.deps$_main.doInvoke(deps.clj:589)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at babashka.impl.deps$add_deps$fn__26947$fn__26948.invoke(deps.clj:101)
    at clojure.lang.AFn.applyToHelper(AFn.java:152)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990)
    at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990)
    at clojure.lang.RestFn.invoke(RestFn.java:425)
    at babashka.impl.deps$add_deps$fn__26947.invoke(deps.clj:101)
    at babashka.impl.deps$add_deps.invokeStatic(deps.clj:101)
    at babashka.main$exec$fn__31702.invoke(main.clj:870)
    at clojure.lang.AFn.applyToHelper(AFn.java:152)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990)
    at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990)
    at clojure.lang.RestFn.invoke(RestFn.java:425)
    at babashka.main$exec.invokeStatic(main.clj:822)
    at babashka.main$main.invokeStatic(main.clj:1165)
    at babashka.main$main.doInvoke(main.clj:1122)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at babashka.main$_main.invokeStatic(main.clj:1198)
    at babashka.main$_main.doInvoke(main.clj:1190)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at babashka.main.main(Unknown Source)

craftybones06:06:45

This isn’t on my machine, it is remote so I might not be able to debug this immediately

craftybones06:06:09

They’ve tried removing .cpcache

craftybones06:06:16

The error still persists

craftybones06:06:19

Not sure what the issue is

borkdude06:06:35

Can you please make a copy of /.deps.clj (archive it as a zip file, so I can repro the problem) and then remove that directory and try again? Please send /.deps.clj to me so I can reproduce the problem locally

borkdude06:06:17

If that doesn't help, please remove ~/.clojure/.cpcache

borkdude06:06:45

The issue may have come from deleting things from ~/.gitlibs manually

borkdude06:06:02

-Sforce should also help

craftybones06:06:46

-Sforce didn’t work.

craftybones06:06:54

@Nitin has shared the zip

craftybones06:06:00

We’ve deleted .cpcache as well

borkdude06:06:24

you should delete ~/.clojure/.cpcache (HOME dir) specifically

Nitin06:06:37

/Users/nitinsharma/.clojure
├── deps.edn
└── tools
    └── tools.edn

1 directory, 2 files

craftybones06:06:50

yeah, done. That’s what .clojure has at the moment

borkdude07:06:51

and this doesn't work?

Nitin07:06:25

yeah, it doesn't work.

borkdude07:06:47

can you try to upgrade to 1.3.182?

borkdude07:06:27

sorry 181 is the latest

Nitin07:06:59

The error has changed now,

Nitin07:06:05

Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
Exception in thread "main" clojure.lang.ExceptionInfo:  babashka.process.Process@63eca275
	at babashka.process$check.invokeStatic(process.cljc:111)
	at babashka.process$shell.invokeStatic(process.cljc:646)
	at babashka.impl.deps$add_deps$fn__27048.invoke(deps.clj:100)
	at borkdude.deps$_main.invokeStatic(deps.clj:969)
	at borkdude.deps$_main.doInvoke(deps.clj:804)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at babashka.impl.deps$add_deps$fn__27055$fn__27056.invoke(deps.clj:106)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at babashka.impl.deps$add_deps$fn__27055.invoke(deps.clj:106)
	at babashka.impl.deps$add_deps.invokeStatic(deps.clj:106)
	at babashka.main$exec$fn__31821.invoke(main.clj:870)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at babashka.main$exec.invokeStatic(main.clj:822)
	at babashka.main$main.invokeStatic(main.clj:1165)
	at babashka.main$main.doInvoke(main.clj:1122)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at babashka.main$_main.invokeStatic(main.clj:1198)
	at babashka.main$_main.doInvoke(main.clj:1190)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at babashka.main.main(Unknown Source)

borkdude07:06:33

can you zip the ~/.deps.clj folder once again?

borkdude07:06:39

and upload it here?

borkdude07:06:46

I'm not sure. You can debug this by adding https://github.com/borkdude/deps.clj (e.g. as a local root so you can make changes to debug) to your deps.edn and then call:

clj -M -m borkdude.deps -Sdeps-file bb.edn

borkdude21:06:56

Did you manage to figure anything out using the above method?

borkdude21:06:26

When you remove /.deps.clj and /clojure/.cpcache and use -Sforce, what do you see the very first time you run bb prepare in the project?

Nitin03:06:11

Deleting ~/.deps.clj and then running just bb worked.

Nitin03:06:15

Thank you very much for the help.

leifericf12:06:17

Does there exist a Babashka-compatible library for copying to the clipboard? Something similar to pbcopy or xclip but cross-platform.

jmglov13:06:10

I'm trying to add some extra dependencies to a bb project like this:

bb \
  -Sdeps '{:extra-deps {jmglov/bblib {:local/root "/home/jmglov/bblib"}}}} \
  --config /home/jmglov/actions/bb.edn \
  -m actions.main
When I try to require a namespace from bblib, I'm getting a "Could not find namespace" exception. My bb.edn looks like this:
{:paths ["src"]}
What am I doing wrong here?

lispyclouds13:06:33

does it work if you pass --deps-root <path to bblib>? along with --config

jmglov13:06:18

Aaaaaah... I had forgotten all about our good friend --deps-root! Lemme try.

jmglov13:06:51

No, that didn't make any difference, sadly.

borkdude13:06:47

Extra’s deps. Only works in an Alia’s

borkdude13:06:57

Fucking phone but I hope you got it

yes 2
jmglov13:06:30

I just tried :deps instead of :extra-deps and that worked.

jmglov13:06:14

Is there any way to add extra deps using -Sdeps, or should I do something like build the classpath myself?

jmglov13:06:16

What I don't want to do is override the deps declared in bb.edn, but rather add to them.

lispyclouds13:06:23

the map passed in -Sdeps will be merged last so more things will be picked up

lispyclouds13:06:01

same keys will prefer the one in -Sdeps

jmglov13:06:45

OK, so if I have {:deps {foo/bar {...}} in my bb.edn and pass -Sdeps '{:deps {baz/blah {...}}', I'll end up with a classpath containing both foo/bar and baz/blah?

👍 2
jmglov13:06:00

Or does it only do a top-level merge?

jmglov13:06:05

OK, lemme test this.

lispyclouds13:06:50

its the same behavior as the jvm clojure cli

jmglov13:06:44

Yeah, so what I put in :deps actually overrides the bb.edn. That's what I was afraid of.

jmglov13:06:11

I'll probably just read in bb.edn and merge the the deps myself, then. That seems like a fairly reasonable solution.

borkdude14:06:11

it doesn't override, it adds extra dependencies, like with the clojure CLI, by merging.

-Sdeps EDN
              Deps data to use as the last deps file to be merged

jmglov06:06:07

You are of course right. I had a little PEBKAC incident over here. 😬

Guilherme Pontes13:06:37

hello. I have a question: is babashka compatible with guava? I was trying to use a https://github.com/deercreeklabs/lancaster and it breaks somewhere related to guava. I remember trying to use the plumatic schema library in the past, too, and having some problems with specific dependencies. does anyone know if it's there are workarounds to use these libraries?

borkdude13:06:20

Bb doesnt support Java libraries

Guilherme Pontes14:06:27

@U04V15CAJ is there any workaround to working with it? someone told me about pods, but I haven't looked into it yet

borkdude14:06:11

plumatic schema now works btw

borkdude14:06:47

pods could be a solution but I doubt it will be a good fit for this problem since pods themselves require serialization of objects

borkdude14:06:53

You could also look at #C029PTWD3HR which runs on Node.js and supports any Node.js library, but not sure what exactly you're looking for

muhanga08:06:17

As a workaround you can use bb to run a clojure programm that will call libs you needed throught the process, but in this case calling clojure directly may be a simpler choice.

teodorlu13:06:14

Shower thought: In bb print-deps, would it make sense to sort the dependencies? I find sorted dependencies easier to read.

2
teodorlu13:06:44

Example of current behavior and proposed behavior:

CURRENT BEHAVIOR
{:deps
 {selmer/selmer {:mvn/version "1.12.50"},
  org.clojure/clojure {:mvn/version "1.11.1"},
  org.clojure/tools.logging {:mvn/version "1.1.0"},
  insn/insn {:mvn/version "0.5.2"},
  org.clojure/tools.cli {:mvn/version "1.0.214"},
  io.github.teodorlu/neil-quickadd {:local/root "."},
  rewrite-clj/rewrite-clj {:mvn/version "1.1.46"},
  babashka/babashka.core
  {:git/url "",
   :git/sha "52a6037bd4b632bffffb04394fb4efd0cdab6b1e"},
  org.flatland/ordered {:mvn/version "1.5.9"},
  org.babashka/babashka.impl.java {:mvn/version "0.1.8"},
  hiccup/hiccup {:mvn/version "2.0.0-alpha2"},
  org.babashka/cli {:mvn/version "0.7.51"},
  org.clojure/data.xml {:mvn/version "0.2.0-alpha8"},
  org.clojure/data.csv {:mvn/version "1.0.0"},
  com.taoensso/timbre {:mvn/version "6.0.1"},
  com.cognitect/transit-clj {:mvn/version "1.0.333"},
  babashka/babashka.curl {:mvn/version "0.1.2"},
  clj-commons/clj-yaml {:mvn/version "1.0.26"},
  org.clojure/core.rrb-vector {:mvn/version "0.1.2"},
  org.babashka/sci.impl.types {:mvn/version "0.0.2"},
  cheshire/cheshire {:mvn/version "5.11.0"},
  babashka/process {:mvn/version "0.5.21"},
  org.clojure/core.match {:mvn/version "1.0.0"},
  org.babashka/http-client {:mvn/version "0.3.11"},
  org.clojure/test.check {:mvn/version "1.1.1"},
  babashka/fs {:mvn/version "0.4.19"},
  org.clojure/data.priority-map {:mvn/version "1.1.0"},
  nrepl/bencode {:mvn/version "1.1.0"},
  org.clojure/core.async {:mvn/version "1.6.673"},
  http-kit/http-kit {:mvn/version "2.7.0-RC1"}}}

PROPOSED BEHAVIOR
{:deps
 {babashka/babashka.core
  {:git/url "",
   :git/sha "52a6037bd4b632bffffb04394fb4efd0cdab6b1e"},
  babashka/babashka.curl {:mvn/version "0.1.2"},
  babashka/fs {:mvn/version "0.4.19"},
  babashka/process {:mvn/version "0.5.21"},
  cheshire/cheshire {:mvn/version "5.11.0"},
  clj-commons/clj-yaml {:mvn/version "1.0.26"},
  com.cognitect/transit-clj {:mvn/version "1.0.333"},
  com.taoensso/timbre {:mvn/version "6.0.1"},
  hiccup/hiccup {:mvn/version "2.0.0-alpha2"},
  http-kit/http-kit {:mvn/version "2.7.0-RC1"},
  insn/insn {:mvn/version "0.5.2"},
  io.github.teodorlu/neil-quickadd {:local/root "."},
  nrepl/bencode {:mvn/version "1.1.0"},
  org.babashka/babashka.impl.java {:mvn/version "0.1.8"},
  org.babashka/cli {:mvn/version "0.7.51"},
  org.babashka/http-client {:mvn/version "0.3.11"},
  org.babashka/sci.impl.types {:mvn/version "0.0.2"},
  org.clojure/clojure {:mvn/version "1.11.1"},
  org.clojure/core.async {:mvn/version "1.6.673"},
  org.clojure/core.match {:mvn/version "1.0.0"},
  org.clojure/core.rrb-vector {:mvn/version "0.1.2"},
  org.clojure/data.csv {:mvn/version "1.0.0"},
  org.clojure/data.priority-map {:mvn/version "1.1.0"},
  org.clojure/data.xml {:mvn/version "0.2.0-alpha8"},
  org.clojure/test.check {:mvn/version "1.1.1"},
  org.clojure/tools.cli {:mvn/version "1.0.214"},
  org.clojure/tools.logging {:mvn/version "1.1.0"},
  org.flatland/ordered {:mvn/version "1.5.9"},
  rewrite-clj/rewrite-clj {:mvn/version "1.1.46"},
  selmer/selmer {:mvn/version "1.12.50"}}}

teodorlu13:06:28

Script for producing the output above:

borkdude13:06:55

Sure

👍 4
teodorlu14:06:20

PR: https://github.com/babashka/babashka/pull/1582 I haven't written any tests. Should this be tested? This is the whole code change:

$ git show 9aa706ee
commit 9aa706ee1971ee75e1dd1e180ea53e4079fd189e
Author: Teodor Heggelund <[email protected]>
Date:   Tue Jun 27 16:08:58 2023 +0200

    `bb print-deps`: sort dependencies

diff --git a/src/babashka/impl/print_deps.clj b/src/babashka/impl/print_deps.clj
index ca0d5c40..593fd836 100644
--- a/src/babashka/impl/print_deps.clj
+++ b/src/babashka/impl/print_deps.clj
@@ -30,6 +30,7 @@
                      'org.hsqldb/hsqldb)
         bb-edn-deps (:deps @common/bb-edn)
         deps (merge deps bb-edn-deps)
+        deps (into (sorted-map) deps)
         paths (:paths @common/bb-edn)
         deps {:deps deps}
         deps (cond-> deps

borkdude14:06:21

> I haven't written any tests. Should this be tested? Only if you want to capture this behavior so that it won't accidentally be reverted in a future release.

👍 2
💡 2
2
borkdude15:06:37

@U3X7174KS It's not clear to me if 👍 means: yeah fuck it, I'll just take the risk, or yes, I'll follow up with a test

teodorlu15:06:36

Thanks. I'll follow up with tests. But I need to install stuff first (like GraalVM), I've never run Babashka from source before.

❤️ 2
borkdude15:06:11

@U3X7174KS you can just execute lein test :only babashka.print-deps-test or whatever. If it works in the JVM, I think this test will also work with graalvm

👍 2
teodorlu17:06:00

I wrote this test (https://github.com/teodorlu/babashka/blob/88a7d12dac74e3ecd5860543651cfe2ee18668a7/test/babashka/print_deps_test.clj#L26-L28), but it doesn't work:

(testing "keys in dep map are sorted"
  (let [deps-data (edn/read-string deps)]
    (is (sorted? (keys (:deps deps-data))))))
clojure.edn/read-string reads into a hash map. And when I ask for keys, I get a different order than the string. Does it make sense to use rewrite-clj for this instead of clojure.edn?

borkdude17:06:24

You could do that. You can use rewrite-edn to get the deps entry and then check if the keys are alphabetically sorted

👍 2
teodorlu17:06:20

Do you prefer rewrite-edn or rewrite-clj? I noticed that rewrite-clj is a toplevel dependency, whereas rewrite-edn only is in the :babashka/dev alias.

borkdude17:06:04

Whatever is easiest for you - rewrite-edn just makes it easier to pull out the relevant node, you will still need rewrite-clj

👍 2