This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-04
Channels
- # adventofcode (6)
- # announcements (1)
- # aws (18)
- # beginners (104)
- # boot (11)
- # cljsrn (31)
- # clojure (49)
- # clojure-dev (16)
- # clojure-europe (2)
- # clojure-greece (9)
- # clojure-houston (1)
- # clojure-italy (12)
- # clojure-nl (3)
- # clojure-spec (46)
- # clojure-uk (148)
- # clojurescript (12)
- # community-development (13)
- # core-async (7)
- # cursive (35)
- # data-science (13)
- # datomic (70)
- # events (1)
- # fulcro (22)
- # hyperfiddle (1)
- # jobs-discuss (10)
- # kaocha (3)
- # off-topic (7)
- # om (2)
- # other-languages (32)
- # parinfer (1)
- # portkey (4)
- # re-frame (3)
- # reitit (12)
- # shadow-cljs (49)
- # spacemacs (1)
- # specter (6)
- # sql (5)
- # tools-deps (58)
Is anyone using https://github.com/clojure/tools.deps.alpha/tree/add-lib effectively? I'm getting a NullPointerException
on clojure.tools.deps.alpha.util.maven/make-session (maven.clj:141)
- seemingly since around the time the zero-day vulnerabilities in the JVM got fixed (but I might be conflating things). No worries if the answer is "this branch isn't supported, don't use it"
could you be more specific about what you're doing?
Calling add-lib
causes that to be thrown
Hmm actually though, not all the time
so, that's a branch, what commit are you using, what is the full call, etc. give me a repro.
calling it with clojure.java-time {:mvn/version 0.3.2}
seems to be the issue.
@alexmiller will do - give me a moment to try and create a minimal repro repo
you don't need a repo - you can put it all in an clj -Sdeps call to start, then whatever expression you're doing
$ clj -Sdeps "{:deps
> {org.clojure/tools.deps.alpha
> {:git/url \""
> :sha \"e160f184f051f120014244679831a9bccb37c9de\"}}}"
Checking out: at e160f184f051f120014244679831a9bccb37c9de
Clojure 1.10.0
user=> (use 'clojure.tools.deps.alpha.repl)
nil
user=> (add-lib 'clojure.java-time {:mvn/version "0.3.2"})
true
user=> (require 'java-time)
Syntax error (IllegalAccessError) compiling at (temporal.clj:324:1).
class clojure.lang.PersistentUnrolledVector$Card1 tried to access field clojure.lang.APersistentVector._hash (clojure.lang.PersistentUnrolledVector$Card1 is in unnamed module of loader clojure.lang.DynamicClassLoader @7a0e1b5e; clojure.lang.APersistentVector is in unnamed module of loader 'app')
@alexmiller I'm not even getting that far, although I can't seem to reproduce the issue in a new repo so now I'm trying to recreate more and more of the state in my user.clj
as to what's happening before I invoke add-lib
.
I get that defaulting to Clojure 1.10. Not sure what clojure.java-time or the dependency clj-tuple assume with clj or java version
Interesting. I've got clojure.java-time
working w/ a 1.10
repo, although I added it via deps.edn
, not dynamically via add-lib
- so I haven't tested it.
clj-tuple seems to be compiled Java classes, certainly possible that doesn't play nice with add-lib
that error doesn't match what you described though re NPE
I'm seeing it w/ other libs as well - but I'm hitting the error while invoking add-lib
, not after (and trying to require it)
While I try and reproduce, here's a stack trace if it helps: https://gist.github.com/rschmukler/8ae09c46ede6bab8d003dc4fe8cccef8
what sha are you using for tools.deps?
e160f184f051f120014244679831a9bccb37c9de
Also it seems to raise the error w/ about 50% of the deps.
ie. I wrote a wrapper that calls add-lib
on my project for everything in deps.edn
(defn sync-libs
"Dynamically refreshes all libs in `deps.edn` and installs any missing"
([] (sync-libs nil))
([?alias]
(let [edn (-> "deps.edn" slurp read-string)
libs (if ?alias
(get-in edn [:aliases ?alias :extra-deps])
(get edn :deps))]
(doseq [[lib-sym lib-spec] libs]
(try
(add-lib lib-sym lib-spec)
(catch NullPointerException e
(println "Error raised for:" lib-sym lib-spec)))))))
But again, this doesn't appear to be an issue in a different project. Still trying to build back up to it happening.
add-lib doesn't re-add any deps it already has btw
That's fine, I was presuming it to be a no-op
(ie. my workflow is I have a file watcher watching deps.edn
and it syncs the libs on change. I'm not doing any diffing)
the error seems to imply you can't make a maven system, but not sure why you wouldn't get an error at that point
(use 'clojure.tools.deps.alpha.util.maven)
(make-system)
That worked (ie. no exception)
well, not really sure. you're doing this under nrepl and it's possible the classloader hierarchy there is having some impact, don't really know.
I haven't seen this reported before (although obviously not many people using this)
I'm actually seeing it even if I don't use nrepl (ie. if I just use a plain ol' clojure
repl)
well, that's useful in ruling things out
But yeah, I appreciate that I'm beyond the bleeding edge w/ this. I'll see if I can reproduce it...
is there any chance you have this happening in multiple threads a the same time?
I don't think so. I thought it might be some sort of race condition but it seems to be consistent in the dependencies that it fails on
(and since it's just a clojure repl, I can't imagine anything spawning threads)
you could try (dotimes [_ 20] (assert (not (nil? (make-session (make-system) default-local-repo)))))
see if you get any nils
Alright, will try momentarily
I guess would also be good to know which java version you are on
I found the library that causes it
So, if you have an existing deps.edn
w/ metasoarous/oz {:mvn/version "1.5.6"}
and then try and invoke add-lib
the errors happen
confirming in my other repo
Yep! That does it. https://github.com/rschmukler/clojure-add-lib-exception
Note that the sync-libs
is commented out. Digging as to why that lib causes it.
λ java --version
openjdk 11.0.2 2018-10-16
OpenJDK Runtime Environment (build 11.0.2+7)
OpenJDK 64-Bit Server VM (build 11.0.2+7, mixed mode)
Might be that library's dependency on https://github.com/clojure-goes-fast/lazy-require
Yep, this looks like it
> Another problem might happen if you mix lazy-require with some other code that does dynamic namespace loading. lazy-require itself makes sure to serialize the loading of namespaces so that nothing breaks because of concurrent loading (e.g., see clojure-emacs/cider#2092). However, if other code also loads namespaces in the background, something might happen. If you ever experience such issues, please file a ticket.
Although, it's not like I'm requiring that lib, or even using it. ie. simply having it in the project (oz, not confirmed that it's this library specifically) causes the issue.
well, certainly sounds likely
oz is using in it's notebook namespaces
well, I guess specifically https://github.com/metasoarous/oz/blob/master/src/clj/oz/notebook/iclojure.clj
Heh, we are doing exactly the same thing 😛
actually that loads it but doesn't use it
Although, I don't think it's actually using it. If you look at the lib itself, it's pure
https://github.com/clojure-goes-fast/lazy-require/blob/master/src/lazy_require/core.clj
ie. it's not like it's doing anything to the run-time or anything