yeah that's what I thought at first but after struggling for a few days I started reaching I guess. knowing it's just supposed to be js, I'm going to try targeting node next and see if that works, thank you for your input!
Hello, I get this error, when use shadow-cljs in WSL ubuntu on Windows, can anyone help? thanks.
shadow-cljs - config: /home/kimim/workspace/vorstellung/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
Execution error (AssertionError) at shadow.build.classpath/process-root-contents (classpath.clj:593).
Assert failed: (sequential? root-contents)
@kimi.im my guess is that you don't have a :source-paths
vector? maybe a set or map?
@ajsnow2012 you don't have to look at node either. unless you need some type of server of course. look literally for "static website"
It is set correctly :source-paths ["src/cljs"] The same setting, works in Linux or windows environment. But WSL failed..
I use WSL too and never had an issue
what is the rest of the stacktrace?
Hello @thheller, the full error looks like this: {:clojure.main/message "Execution error (AssertionError) at shadow.build.classpath/process-root-contents (classpath.clj:593).\nAssert failed: (sequential? root-contents)\n", :clojure.main/triage {:clojure.error/class java.lang.AssertionError, :clojure.error/line 593, :clojure.error/cause "Assert failed: (sequential? root-contents)", :clojure.error/symbol shadow.build.classpath/process-root-contents, :clojure.error/source "classpath.clj", :clojure.error/phase :execution}, :clojure.main/trace {:via [{:type java.lang.AssertionError, :message "Assert failed: (sequential? root-contents)", :at [shadow.build.classpath$process_root_contents invokeStatic "classpath.clj" 593]}], :trace [[shadow.build.classpath$process_root_contents invokeStatic "classpath.clj" 593] [shadow.build.classpath$process_root_contents invoke "classpath.clj" 593] [shadow.build.classpath$find_jar_resources invokeStatic "classpath.clj" 670] [shadow.build.classpath$find_jar_resources invoke "classpath.clj" 638] [shadow.build.classpath$find_resources invokeStatic "classpath.clj" 767] [shadow.build.classpath$find_resources invoke "classpath.clj" 758] [shadow.build.classpath$index_path_STAR_ invokeStatic "classpath.clj" 997] [shadow.build.classpath$index_path_STAR_ invoke "classpath.clj" 994] [clojure.lang.PersistentVector reduce "PersistentVector.java" 343] [clojure.core$reduce invokeStatic "core.clj" 6827] [clojure.core$reduce invoke "core.clj" 6810] [shadow.build.classpath$index_classpath$fn__10836$fn__10837 invoke "classpath.clj" 1130] [clojure.lang.Atom swap "Atom.java" 37] [clojure.core$swap_BANG_ invokeStatic "core.clj" 2352] [clojure.core$swap_BANG_ invoke "core.clj" 2345] [shadow.build.classpath$index_classpath$fn__10836 invoke "classpath.clj" 1130] [shadow.build.classpath$index_classpath invokeStatic "classpath.clj" 1129] [shadow.build.classpath$index_classpath invoke "classpath.clj" 1124] [shadow.build.classpath$index_classpath invokeStatic "classpath.clj" 1126] [shadow.build.classpath$index_classpath invoke "classpath.clj" 1124] [shadow.cljs.devtools.server.common$fn__15586 invokeStatic "common.clj" 92] [shadow.cljs.devtools.server.common$fn__15586 invoke "common.clj" 90] [clojure.lang.AFn applyToHelper "AFn.java" 154] [clojure.lang.AFn applyTo "AFn.java" 144] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.core$apply invoke "core.clj" 660] [shadow.runtime.services$start_one invokeStatic "services.clj" 98] [shadow.runtime.services$start_one invoke "services.clj" 87] [shadow.runtime.services$start_many$fn__9395 invoke "services.clj" 127] [shadow.runtime.services$start_many invokeStatic "services.clj" 126] [shadow.runtime.services$start_many invoke "services.clj" 105] [shadow.runtime.services$start_all invokeStatic "services.clj" 144] [shadow.runtime.services$start_all invoke "services.clj" 139] [shadow.cljs.devtools.server$start_system invokeStatic "server.clj" 340] [shadow.cljs.devtools.server$start_system invoke "server.clj" 202] [shadow.cljs.devtools.server$start_BANG_ invokeStatic "server.clj" 483] [shadow.cljs.devtools.server$start_BANG_ invoke "server.clj" 385] [shadow.cljs.devtools.server$start_BANG_ invokeStatic "server.clj" 388] [shadow.cljs.devtools.server$start_BANG_ invoke "server.clj" 385] [shadow.cljs.devtools.server$from_cli invokeStatic "server.clj" 615] [shadow.cljs.devtools.server$from_cli invoke "server.clj" 591] [clojure.lang.AFn applyToHelper "AFn.java" 160] [clojure.lang.AFn applyTo "AFn.java" 144] [clojure.lang.Var applyTo "Var.java" 705] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.core$apply invoke "core.clj" 660] [shadow.cljs.devtools.cli_actual$lazy_invoke invokeStatic "cli_actual.clj" 23] [shadow.cljs.devtools.cli_actual$lazy_invoke doInvoke "cli_actual.clj" 20] [clojure.lang.RestFn invoke "RestFn.java" 460] [shadow.cljs.devtools.cli_actual$blocking_action invokeStatic "cli_actual.clj" 129] [shadow.cljs.devtools.cli_actual$blocking_action invoke "cli_actual.clj" 116] [shadow.cljs.devtools.cli_actual$main invokeStatic "cli_actual.clj" 177] [shadow.cljs.devtools.cli_actual$main doInvoke "cli_actual.clj" 132] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.core$apply invokeStatic "core.clj" 669] [clojure.core$apply invoke "core.clj" 660] [shadow.cljs.devtools.cli_actual$_main invokeStatic "cli_actual.clj" 219] [shadow.cljs.devtools.cli_actual$_main doInvoke "cli_actual.clj" 217] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.lang.Var applyTo "Var.java" 705] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.core$apply invoke "core.clj" 660] [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 75] [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 67] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.lang.Var applyTo "Var.java" 705] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.main$main_opt invokeStatic "main.clj" 514] [clojure.main$main_opt invoke "main.clj" 510] [clojure.main$main invokeStatic "main.clj" 664] [clojure.main$main doInvoke "main.clj" 616] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.lang.Var applyTo "Var.java" 705] [clojure.main main "main.java" 40]], :cause "Assert failed: (sequential? root-contents)"}}
which java version?
yeah its a bad .jar
file on the classpath causing this
something that pretends to be a .jar
but isn't
most likely from your java dist
openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06) OpenJDK 64-Bit Server VM GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06, mixed mode, sharing)
you can set :log {:level :debug}
in your shadow-cljs.edn
. that should then log which one causes the trouble
Thanks. It says one deps jar is empty: [2021-01-26 09:14:44.403 - FINE] :shadow.build.classpath/bad-jar - {:file #object[http://java.io.File 0x7b8bf5c0 "/home/kimim/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar"]} ZipException zip file is empty
just delete it
redownload probably fixes it
It works now. Thanks.
hey, I'm getting an issue using node when I try to require a cljs file which itself requires a string path javascript file, but I don't really get a stack trace, just "failed to import" and then "SHADOW ERROR" and the path
sorry SHADOW import error
I made progress, that file is in my output watch artifact, I manually modified it to log the error, which told me the problem was another missing module: Module not provided: shadow.js.shim.module$chai, however this module is in the root node_modules
@zimablue I don't understand what you mean by however this module is in the root node_modules
. what is your build config and how are you running it?
hi Mr Heller, the overall purpose is to try and test datascript which I am consuming through javascript, so in my actual project I use datascript though javascript which works fine but can't debug it, I was trying to jam part of my javascript project in as a datascript-repl dependency so I could use clojure debugging and understand the Clojure project, To that end I am connecting calva to a node-library build, the repl works and I can import datascript modules. I then just dumped my javascript node_modules and output lib into a subdirectory of the datascript project. It works to some extent but fails to resolve when one javascript file imports another, my build looks like this:
builds {:node {:target :node-library ;; :main {:entries [test_node.js]} :js-options {:js-package-dirs ["vscodelib", "node_modules"] ;; :js-provider :require } :output-to "./lib" :exports {:dunno datascript.js/keywordize}}
and the error I get after I manually overwrite my output artifact to print the error is:
(in node)
shadow-cljs - failed to load module$vscodelib$test$databasespec SHADOW import error /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js Module not provided: shadow.js.shim.module$chai
Chai being a javascript dependency of the javascript file which I am importing
sorry, please don't waste any time on this since I am very new so it's certainly a failure of my understanding
but if you can immediately guess the problem that would be cool also
yeah sorry I can't help much. it seems like you are trying to do something weird but I don't understand what
cljs-runtime/marc.js
suggests you have a (ns marc)
which I don't see in your config so no clue
:js-package-dirs ["vscodelib", "node_modules"]
this is also suspect. why are you doing this?
no clue how chai
plays into all of this. datascript doesn't use it.
"dumped my javascript node_modules and output lib into a subdirectory" this will definitely not work and is not supposed to
what is the recommended alternative approach for consuming js code? it has to be formatted as npm packages?
it sounds to me like you want the opposite route? consume the CLJS code in a JS build? if your code is mostly JS?
I'm doing that successfully, the reason for this reversal is for development, so that I can debug a clojurescript library using clojurescript repl/tooling
debug "where"?
I mean where is the final JS running?
:node-library
isn't really meant to be re-bundled. it is meant to be used in node directly. (as the name implies 🙂)
the final js is intended to run as you said, consuming the clojurescript, this is just intended to run in my repl/run tests so I can poke around the clojurescript dependencies
(this alternative setup)
since it's hard to use javascript tools to understand what clojurescript libraries are doing with your datastructures I tried to set up a version of the reverse setup to enable me to use cljs tooling
ok. what kind of JS code do you have? plain standard ES6+ code or some kind of other dialect? JSX? etc?
it's typescript which has been compiled to es5 modules
I think
ok, did you follow https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js
I'm certain that's what happens, but not sure that my description is useful
better to compile to es8 or so but es5 isok
thanks, I have looked at this document but not read every line, I will reread this section
thank you for your help
you may also try :npm-module
which will might work better for your use-case
ah yes I read this section, then by trial and error made it work by requiring in my cljs like this: (ns marc (:require ["/vscodelib/test/databasespec.js" :as foo])) That call works, but when databasespec.js has a further dependency (require("chai")), that's when I get the error I pasted
I will try npm-module
I started to read the shadow-cljs source code but it seems fairly complex
so you have :source-paths ["src"]
and src/vscodelib
? the :js-package-dirs
is misleading here and probably causing issue
yes I have both of those, I think that was what worked (or at least gave me a new error message) by trial and error
ideally the code you use this way uses ESM syntax so not require("chai")
but import Foo from "chai"
(ns marc (:require ["/vscodelib/test/databasespec.js" :as foo]))
what is your :source-paths
?
sorry wrong paste
vscodelib
makes me suspicious. is this running as a vscode
plugin of some kind?
{ :verbose true :log {:level :debug} :source-paths [ "src" ] :dependencies [[persistent-sorted-set "0.1.2"]] :builds {:node {:target :node-library ;; :main {:entries [test_node.js]} :js-options {:js-package-dirs ["vscodelib", "node_modules"] ;; :js-provider :require } :output-to "./lib" :exports {:dunno datascript.js/keywordize}}}}
ok so the above would look for src/vscodelib/test/databasespec.js
yes which is where it is
that part I believe works, it's the next dependency resolution, js=>js
so that JS file has a require("chai")
?
yes
which I think is the result of a typescript compilation with target "es5"
well it should not have require
at all. it should have import
but require
should also work
how are you running any of this?
I start shadow-cljs server, shadow-cljs watch node, npm=>import "./lib" and then finally through calva connect to the running repl
sorry if that's a pedantic description as you can tell I'm new to this ecosystem
npm=>import "./lib"
what does that mean?
sorry
• "node => import lib"
i start node in a terminal then import the output artifact
which provides the runtime (?)
please post what exactly you are doing. you are forcing me to guess which helps noone.
as in (calva) <=> (shadow-cljs watch) <=> (node with loaded code)
I was trying to be precise
you are literally running node
and then import lib
? that is invalid?
no I run node and then "require("lib")
sorry I got the verbs confused
please be more precise
require("lib")
this would be looking for node_modules/lib
? which no output is going to
I need to understand what you are doing to provide any kind of help
lib is where the node watch process outputs the javascript artifact
this line in my shadow-cljs.edn: :output-to "./lib"
I believe configures that
yes. but require("lib")
will NOT look for that output at least not with the default node
configuration
it's require ("./lib")
sorry
ok thanks
ok first of all why are you doing this at all?
why not just shadow-cljs node-repl
or that via Calva?
but ok, lets try to make this work
I think I tried that and it didn't work, so I tried to run the individual commands
you open node
. you run require("./lib")
. what happens next?
to at least vaguely understand what what happening
then I go to calva and do "connect to running repl", some magic happens and I can communicate with that process
no. what happens in the node process
not interested in calva at this time
I get this output
> require("./lib") { dunno: [Getter] } > shadow-cljs - #6 ready!
ok that appears to work fine then
now please run shadow-cljs cljs-repl node
no calva
then eval something like :foo
just to verify the connection works
the shadow-cljs cljs-repl node gives "shadow-cljs: command not found"
ok if you don't have the global install run npx shadow-cljs cljs-repl node
instead
yes sorry I see I was using npx for the others
it connects and runs simple commands
ok and what command did you run to "break" things?
(require 'marc)
ok and that still breaks things now? trying to take calva out of the equation here
yes
with what error? the above Module not provided I assume?
same problem: shadow-cljs - failed to load module$vscodelib$test$databasespec SHADOW import error /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js now before I had gotten more information about the error by modifying the output "lib" artifact and adding a line which logs the error
remove :exports {:dunno datascript.js/keywordize}}
from your build config and instead use :exports {:dunno marc/foo}}
and if I repeat that I get
shadow-cljs - failed to load module$vscodelib$test$databasespec SHADOW import error /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js Module not provided: shadow.js.shim.module$chai /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js
referring to the js=> js import
ok
need to have an actual def
in that ns
though. you can use any you already have or just add (def foo 3)
point is getting that ns into the initial build so we can get to the error "earlier", ie. trigger it on build or on load, not the REPL
also remove :js-options
completely
before i removed js-options, you are right this moved the error from the repl stage to the node require("./lib") stage
same error
trying without js-options
ok, I'm guessing you are running into a variant of this https://github.com/thheller/shadow-cljs/issues/832
so, try node
then global.shadow$provide = {};
then require("./lib")
same result without js-options
also I don't understand why you are not getting that error
can you share this file src/vscodelib/test/databasespec.js
?
without js-options and with the suggested node argument I get the same error
here:
ok var datascript_1 = require("datascript");
this is a problem and probably causing all the rest
that will include the npm datascript
package. not the one compiled by shadow-cljs you are doing all this for
any shadow-expert who can help me with this How to solve this one :
cljs꞉cljs.user꞉> @state/orders
nil
; No available JS runtime.
clj꞉cljs.user꞉> @state
shadow-cljs.edn
{:source-paths ["src"]
:dependencies [[binaryage/devtools "0.9.10"]
[proto-repl "0.3.1"]
[reagent "0.8.0"]]
:nrepl {:port 3333}
:builds
{:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules
{:main
{:entries [giggin.core]}}
:devtools
{:after-load giggin.core/main
:http-root "public"
:http-port 3000}}}}
@roelof open <http://localhost:3000>
in the browser. see https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting
that one is open
what does the browser console say?
@thheller, I see - I think this problem might be separate, since the chai importation is direct in this file not through datascript. What should that import look like and do you have any idea how I nudge typescript to compile it so that it requires correctly?
I get a warning in my react-native app: the shadow-cljs websocket was disconnected.
Do you know what’s the cause?
it seems like it’s connected successfully since the app correctly loads.
no that doesn't mean anything. the websocket is injected by shadow-cljs to provide the hot-reload and REPL. it does not effect the app loading part.
but it may fail to connect if it picked the wrong IP or so
but without more info I cannot help you
I’m not exactly sure what info to provide
I see two messages
Warning: The tag <orders> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.
CLJS DevTools: some custom formatters were not rendered.
I see the posted message on repl of VS Code
no. did it ever connect successfully?
well there isn't really any way to do this
since the datascript
npm package is bundled differently and not by shadow-cljs
yeah I really don't think the way you are trying this is going to work
I see, thanks for all your help I learned something hopefully
is a better approach to try and bundle the javascript into an npm package shape, whatever that is
since shadow-cljs knows how to consume that?
I want to show the contents of this :
(ns giggin.state
(:require [reagent.core :as r]))
(def orders (r/atom {}))
@roelof this ; No available JS runtime.
means that the browser has not connected back to shadow-cljs. that is the only issue you need to solve. the code does not matter. I cannot solve this for you without more info. the build config you provided will have generated a public/js/main.js
. I assume you have a public/index.html
file with a <script src="/js/main.js">
?
no that won't do anything
yes
the issue is getting JS->CLJS->JS->JS working
and I tried also (js/alert "test")
and then I saw a popup so it seems there is a js runtime
and you don't get a shadow-cljs ready
message in the browser console?
wait now there is a runtime?
if I do the alert there seems to be a runtime
and what do you get via giggin.state/order
?
yes, I see this message : `shadow-cljs: #7 ready!`
ok. that is your runtime
did you try the REPL stuff before opening the page?
then it seems to work
`cljs꞉cljs.user꞉> giggin.state/orders #<Atom: {}>`
yep, then everything works then
thanks
that's not strictly necessary, I'm only trying to test some isolated pieces, I don't need to go datascript=>js=>datascript, I just commented those parts. I also rearranged to check and all the inter-project direct imports work, it's just anything that assumes it's going to see a node_modules and does like that unqualified import like var ramda = require("ramda")
so if I can just go datascript => js => (assumed node_modules import) I will have enough to do the poking that I was hoping for
thanks so much, do you have any simple menial task I could do as compensation for your help?
(help so far)
Hi, this may be a question for graal js but thought I'd give it a go. Has anyone managed to get shadow-cljs to output js that can be loaded via graal context?
Currently I'm playing with :target :esm
which has got me further than I have been...
there is an undocument :target :graaljs
which sort of works for most stuff
Cheers, I'll give that a blast and have a look at the source.
just :entries [whatever.ns] :output-to "foo/bar.js"
it has no support for running graaljs context or so. that you have to do yourself.
no REPL or hot-reload either since the default context doesn't support it. I can show some code to sort of get it but its pretty specific to how you create and use the graal context
If you have some example code it would be great. I'm currently going off nothing so anything is helpful.
well what do you intend to do with graal?
Using it for ssr a reagent app.
I started using shadow a couple of years back because of the great npm support but now have to get that app ssr'ing, graal because of the performance uplift.
https://nextjournal.com/kommen/react-server-side-rendering-with-graalvm-for-clojure
performance is generally a lot worse than node
startup time is horrible
and no support for async whatsoever is rather limiting
they have since moved to shadow-cljs and I implemented the :target :graaljs
for them as well as some custom code so they get some hot-reload
Looks like it would be wise to go back to ol' fashioned jvm
i don’t know what the websocket is
How can I start a repl that I can tap into with (shadow/repl) but without reloading the server on every change?
I want to write some code in the repl but don't want to lose state on every change
def
's get re-evaluated and overwritten, running shadow-cljs watch
, if I have state that I don't want to get re-initialized and re at the def
form, there's defonce
.
I tried the browser repl but I can't connect via Cursive because it returns this error
(shadow/repl :app)
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.nrepl-impl/repl-init (nrepl_impl.clj:28).
watch for build not running
“watch for build not running”. Have you tried (shadow/watch :app)
first?
> ... but don't want to lose state on every change
that is your code losing the state. you can fix that. you can also run (shadow/watch :app {:autobuild false})
so it doesn't automatically recompile if thats what you are asking
also just (shadow/node-repl)
is usually good enough if you just want a repl