Fork me on GitHub
#babashka
<
2019-12-08
>
sogaiu14:12:16

curious though -- shouldnt': > nREPL connections: jet be: > nREPL connections: rep ? or may be there's something about jet i don't know? 🙂

plexus19:12:52

Ah yeah thanks, I'll fix it

sogaiu14:12:39

on a side note, there was recent discussion about examining classpaths -- i mentioned sed and then ghadi mentioned tr (for splitting on the separator)

borkdude14:12:53

@sogaiu are you reacting to what I just said in #clojure ?

sogaiu14:12:20

@borkdude no, it was just a remark related to the article -- don't have an answer for your question in #clojure

borkdude14:12:36

This seems to work:

user=> (def cl (.URLClassLoader. (into-array .URL [(.URL. "file:///Users/borkdude/.m2/repository/com/cognitect/transit-java/0.8.337/transit-java-0.8.337.jar")])))
#'user/cl
user=> (.findResource cl "com/cognitect/transit/Reader.class")
#object[.URL 0x3e30646a "jar:file:/Users/borkdude/.m2/repository/com/cognitect/transit-java/0.8.337/transit-java-0.8.337.jar!/com/cognitect/transit/Reader.class"]

borkdude14:12:54

I might be able to resolve files by namespace and just load them from the classpath in babashka

borkdude14:12:04

then you can deploy babashka libs to clojars etc

sogaiu15:12:21

interesting -- will it be important to be able to tell clj libs apart from bb libs (at least on clojars)? i like the "etc" part -- using git hashes has been nice in deps.edn

borkdude20:12:20

$ cat /tmp/foo/bar.clj
(ns foo.bar)

(defn hello []
  (println "hello world"))

$ lein bb --classpath /tmp "(require '[foo.bar :as b]) (b/hello)"
hello world

$ ./bb --classpath /tmp "(require '[foo.bar :as b]) (b/hello)"
Could not require foo.bar. [at line 1, column 1]

borkdude20:12:10

(i.e. URLClassLoader seems to return null in native-image where it shouldn't)

borkdude21:12:20

Cool new tool based on sci: <https://github.com/liquidz/daddy>

sogaiu21:12:36

also using native-image iiuc

sogaiu22:12:46

@borkdude does this seem relevant? > To make calls such as Class.getResource(), Class.getResourceAsStream() (or the corresponding ClassLoader methods) return specific resources (instead of null), the resources that should be accessible at image runtime need to be explicitly specified. via: https://github.com/oracle/graal/blob/master/substratevm/RESOURCES.md

borkdude22:12:48

@sogaiu hmm, if this is only possible with compile time resources then this won't work

borkdude22:12:03

my idea was to have a classpath than you can search for a file

borkdude22:12:15

so require knows what to load, at run time

borkdude22:12:25

but I'm not calling Class.getResourcesAsStream, but a very specifically created URLClassLoader .getResourceAsStream

borkdude22:12:38

so I would still expect that to work. I'm not querying the normal JVM classpath

sogaiu22:12:06

may be you'll get some feedback at your issue at some point

borkdude22:12:12

if this doesn't work, there's probably the workaround of doing all of this manually

borkdude22:12:25

like: walking through every dir and .jar file to check if the file(s) exists