This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-29
Channels
- # announcements (6)
- # beginners (110)
- # calva (18)
- # clj-kondo (19)
- # cljs-dev (27)
- # clojars (10)
- # clojure (38)
- # clojure-art (2)
- # clojure-europe (13)
- # clojure-germany (1)
- # clojure-norway (26)
- # clojure-uk (2)
- # clojurescript (10)
- # conjure (9)
- # cursive (12)
- # data-science (3)
- # datomic (22)
- # emacs (8)
- # helix (9)
- # honeysql (18)
- # introduce-yourself (1)
- # jobs (1)
- # leiningen (8)
- # lsp (22)
- # missionary (9)
- # nbb (11)
- # off-topic (83)
- # pathom (5)
- # pedestal (4)
- # polylith (1)
- # portal (1)
- # re-frame (3)
- # reitit (15)
- # remote-jobs (1)
- # rum (4)
- # shadow-cljs (88)
- # specter (12)
- # testing (1)
- # vim (39)
I'm running into an issue with UUIDs generated with (random-uuid)
, conditional upon requiring meander. Details in thread...
This works fine:
$ clj -Sdeps '{:deps {meander/epsilon {:mvn/version "0.0.650"}}}'
Clojure 1.10.3
(require '[meander.epsilon :as m])
Reflection warning, meander/util/epsilon.cljc:758:24 - reference to field val can't be resolved.
nil
(identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
But when using shadow:
shadow-cljs - starting via "clojure"
shadow-cljs - server version: 2.19.5 running at
shadow-cljs - nREPL server started on port 9000
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
shadow.user=> (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
shadow.user=> (require '[meander.epsilon :as m])
Reflection warning, meander/util/epsilon.cljc:758:24 - reference to field val can't be resolved.
nil
shadow.user=> (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
Execution error (NumberFormatException) at shadow.user$eval36582/<clinit> (REPL:3).
Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
And strangely enough, this works:
shadow.user=> (do #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
Sorry, I should have mentioned that it's a clj-repl started with:
npx shadow-cljs clj-repl -A:shadow-cljs
shadow.user=> cljs.reader/*tag-table*
Syntax error (ClassNotFoundException) compiling at (REPL:0:0).
cljs.reader
I'm not sure if it worked..? Looks like it produced a syntax error and a value?i though it was cljs, in that case that would be default-data-readers
and *data-readers*
shadow.user=> *data-readers*
{dbg #'cider.nrepl.middleware.debug/debug-reader, break #'cider.nrepl.middleware.debug/breakpoint-reader, light #'cider.nrepl.middleware.enlighten/light-reader, meander.epsilon/fail #'meand
er.strategy.epsilon/*fail*, meander.epsilon/pass #'meander.strategy.epsilon/*pass*}
$ java --version
openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.21.10.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.21.10.1, mixed mode, sharing)
shadow.user=> #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
shadow.user=> (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
Execution error (NumberFormatException) at shadow.user$eval36931/<clinit> (REPL:5).
Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
shadow.user=> (prn #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
Execution error (NumberFormatException) at shadow.user$eval36933/<clinit> (REPL:6).
Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
shadow.user=>
Yep.Perhaps there's something extra running I'm not aware of? Is there some way to get more diagnostics or make it run with a bare config?
java.lang.ExceptionInInitializerError
is always responsible for some very weird errors
also do you have something in your ~/.clojure/deps.edn
or wherever that file is? maybe there is something in there contributing to this? no idea what but maybe?
also you can set {:deps {:aliases [:shadow-cljs]}}
in shadow-cljs edn so you don't have the pass the -A:shadow-cljs
in case you didn't know that
And yes, happens over nrepl too:
+14:16 $ clj -A:repl/cider
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
nREPL 0.9.0
Clojure 1.11.1
OpenJDK 64-Bit Server VM 11.0.15+10-Ubuntu-0ubuntu0.21.10.1
Interrupt: Control+C
Exit: Control+D or (exit) or (quit)
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
(identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
Execution error (NumberFormatException) at shadow.user$eval40895/<clinit> (REPL:1).
Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
shadow.user=>
I guess I could ask in #meander? It does seem related, since the identity
call works before requiring it. Otherwise I too have no ideas. It's strange that it works with some forms, like do
, and
, or
, but not most others. I guess those working ones don't evaluate it or something.
I'm sorry, this is very frustrating because it has happened to me in the past. Somehow after deleting my .m2 folder and reinstalling Clojure, the problem is gone. I have no idea how my .m2 is getting screwed up or how I can detect that it's in a broken state to avoid another goose chase like this. I don't interact with that folder manually.
@U05224H0W guess I can't rule it out completely. There was a lengthy https://clojurians.slack.com/archives/C053AK3F9/p1656530805008529 about this in #beginners. Unfortunately, didn't really come to a resolution because I deleted the evidence (~/.m2 folder), but there are some good guesses in there. Leaving it here for reference.
good afternoon. i'm experimenting w/ code splitting.
{:builds
{:dev
{:target :node-script
:main shadowtest.core/main
:output-to "build/shadowtest/app.js"
:module-loader true
:modules
{:hotload
{:entries [shadowtest.hotload]}}}
(ns shadowtest.core
(:require
[shadow.loader :as loader]))
(defn do-load!
[n]
(println "Loading module '" n "'.")
(-> (loader/load n)
(.then identity)))
attempting to drive it in the repl:
(do-load! "hotload")
emits:
Execution error (Error) at (<cljs repl>:1).
shadow.loader API was called before shadow.loader.init!
You are probably calling module loader too early before shadow-cljs got fully initialized.
was there a step i missed when attempting this?
no, im hoping to run this via nodejs
gotcha. i have a case for it, but that answer satisfies the question
i would like to have a similar effect of requiring-resolve on cljs on node (at the compile step)
perhaps. will read up on it
ideally would like to have a generated shadow-cljs.edn file, which uses :modules and :entities like interfaces inside the application. user can swap out implementations at compile time w/o fooling with the cljs code
I mean just having all the code loaded and then using your own mechanism to switch between different impls would be easy
i dont have any pre-sight into the actual namespace names
was hoping :modules would abstract it
i don't see that i can require up-front
modules only abstract the splitting of one output file into many. the inputs are the same.
got it
assume i'm going to take string messages from an ingress source. this may be kafka, jms, http, or other. these are expected to have a common entry point fn with the same signature (arity, etc). these may be in their own namespaces. I was originally thinking i could use :modules to identify "ingress" with :entities [the.actual.namespace], and shadow.loader/load "ingress" I can construct the shadow-cljs.edn file programically.
on the jvm i can do this w/ requiring-resolve
sorry yes, my mistake
so you are triggering a shadow-cljs build dynamically and then somehow run the generated output?
assume that each change or difference would involve a whole build step
and it launches an entierely new process? you are not trying to load it some running script?
i don't expect it to happen at run time
the real target is to avoid (require '[some.namespace.i.dont.know :as ingress])
thats the whole task
that in clojure would do ((requiring-resolve 'some/thing) :foo :bar)
but can't in CLJS
it wont change after compile. assume that each customer that may change implementation has their own compilation, process, etc
that is what will occur, yes. the selection of implementation, and therefore the generation of shadow-cljs.edn, will happen during a docker image build
I mean instead of generating a build config you can just as well generate a namespace
i could, yea
and then generate (ns some.thing (:require [whatever.you.need])) (defn main [] ...)
dynamically
thats not a bad idea..
let me consider that. thanks for the idea
and it'll be more explicit, too
please be aware that shadow-cljs is a development tool. it is not meant to ever run in any kind of production environment.
it will expose several sockets for nrepl, its own websocket server and so on which may compromise production envs
understood
and thanks for your work on the project