Fork me on GitHub
#shadow-cljs
<
2022-03-25
>
Eva O19:03:15

I'm trying to run npx shadow-cljs server but I'm running into an error:

shadow-cljs - starting via "clojure"
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.

Full report at:
/var/folders/kh/tgss0d8s04v0xh2mtztlfw2r0000gn/T/clojure-15894664129410946386.edn

Eva O19:03:10

The full report:

{:clojure.main/message
 "Execution error (FileNotFoundException) at clojure.main/main (main.java:40).\nCould not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.\n",
 :clojure.main/triage
 {:clojure.error/class java.io.FileNotFoundException,
  :clojure.error/line 40,
  :clojure.error/cause
  "Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.",
  :clojure.error/symbol clojure.main/main,
  :clojure.error/source "main.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.io.FileNotFoundException,
    :message
    "Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.",
    :at [clojure.lang.RT load "RT.java" 462]}],
  :trace
  [[clojure.lang.RT load "RT.java" 462]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6908 invoke "core.clj" 6161]
   [clojure.core$load invokeStatic "core.clj" 6160]
   [clojure.core$load doInvoke "core.clj" 6144]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5933]
   [clojure.core$load_one invoke "core.clj" 5928]
   [clojure.core$load_lib$fn__6850 invoke "core.clj" 5975]
   [clojure.core$load_lib invokeStatic "core.clj" 5974]
   [clojure.core$load_lib doInvoke "core.clj" 5953]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 6016]
   [clojure.core$load_libs doInvoke "core.clj" 6000]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 6038]
   [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
  "Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath."}}
I'm using version 2.17.8 for both JS and Clojure. My deps.edn:
{:paths ["src/main", "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.11.0"}
        com.fulcrologic/fulcro {:mvn/version "3.5.15"}
        com.taoensso/timbre {:mvn/version "5.2.1"}}
 
 :aliases {:dev {:extra-paths ["src/dev"]
                 :extra-deps {org.clojure/clojurescript {:mvn/version "1.11.4"}
                              binaryage/devtools {:mvn/version "1.0.5"}
                              cider/cider-nrepl {:mvn/version "0.28.3"}
                              thheller/shadow-cljs {:mvn/version "2.17.8"}}}}}
My shadow-cljs.edn:
{:deps {:aliases [:dev]}
 :dev-http {8000 "classpath:public"}
 :builds {:main {:target :browser
                 :output-dir "resources/public/js/main"
                 :asset-path "/js/main"
                 :modules {:main {:init-fn quizlet.client/init
                                  :entries [quizlet.client]}}
                 :devtools {:after-load quizlet.client/refresh
                            :preloads [com.fulcrologic.fulcro.inspect.preload
                                       com.fulcrologic.fulcro.inspect.dom-picker-preload
                                       quizlet.development-preload]}}}}

thheller19:03:40

that error you get when shadow-cljs is not on the classpath

Eva O19:03:55

How do I add it to the classpath?

thheller19:03:59

might be some bad cache or maybe the jar download was aborted and is incomplete?

thheller19:03:06

try deleting your .cpcache folder

thheller19:03:24

when that doesn't work delete ~/.m2/repository/thheller/shadow-cljs

thheller19:03:28

otherwise looks fine

Eva O19:03:40

Same error except it also includes WARNING: Specified aliases are undeclared: [:-A]

thheller19:03:27

hmm weird. which OS is this?

thheller19:03:33

this is a regular tools.deps install I assume? maybe thats outdated or broken somehow?

Eva O19:03:05

MacOS 12.2.1

thheller19:03:05

via :deps you are telling shadow-cljs to run tools.deps clojure command. that should be fine but may break if thats not the standard thing

Eva O19:03:33

What is tools.deps?

thheller19:03:34

you can try clojure -A:dev -M -m shadow.cljs.devtools.cli server

Eva O19:03:07

Same error

thheller19:03:19

what is clojure?

thheller19:03:06

what is the clojure command for you?

thheller19:03:57

dunno how you installed it

Eva O20:03:07

Both clojure and clj give the same output

Eva O20:03:26

The weird thing is that it works in other projects. It's just this new one that's breaking

thheller20:03:57

clj -version?

thheller20:03:02

what I have seen before is some not-visible unicode char as the first char in deps.edn

thheller20:03:34

or somewhere else? forgot how to figure that out though

Eva O20:03:50

Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-version (No such file or directory)

Full report at:
/var/folders/kh/tgss0d8s04v0xh2mtztlfw2r0000gn/T/clojure-9249228989860048614.edn

Eva O20:03:05

That's what I get when I run clj -version

thheller20:03:22

hmm there is definitely something weird then? might just be super old? I get

$ clj -version
Clojure CLI version 1.10.3.855

thheller20:03:10

maybe clj -Sdescribe?

Eva O20:03:18

My version is 1.11.0. I checked by just running clj

thheller20:03:34

no, that is the clojure version. not the version of the clj tool itself

Eva O20:03:57

clj -Sdescribe
{:version "1.10.1.561"
 :config-files ["/usr/local/Cellar/clojure/1.10.1.561/deps.edn" "/Users/eoogbe/.clojure/deps.edn" "deps.edn" ]
 :config-user "/Users/eoogbe/.clojure/deps.edn"
 :config-project "deps.edn"
 :install-dir "/usr/local/Cellar/clojure/1.10.1.561"
 :config-dir "/Users/eoogbe/.clojure"
 :cache-dir ".cpcache"
 :force false
 :repro false
 :resolve-aliases ""
 :classpath-aliases ""
 :jvm-aliases ""
 :main-aliases ""
 :all-aliases ""}

thheller20:03:13

hmm yeah that is kinda old

thheller20:03:28

maybe try upgrading that

Eva O20:03:16

I don't remember how I initially installed clojure since it was a long time ago. Since I'm using a Mac, I would assume I did it through brew. However brew upgrade clojure/tools/clojure doesn't work. I'm going to try to reinstall with brew. Hopefully it doesn't clobber it

thheller20:03:05

I'm not sure why it wouldn't work either. maybe try asking in #tools-deps. that error about missing alias is definitely weird

thheller20:03:11

seems declared fine to me but thats the root of the problem it seems

ag20:03:27

Does anyone know, when used with github actions, shadow-cljs doesn't cache jars that shadow uses, and they keep getting re-downloaded each time. Has anyone dealt with this?

šŸ˜• 1
thheller05:03:19

you need to setup caching yourself. I don't have a guide for that but I'm sure there is one. regular maven caching will do

FlavaDave23:03:15

trying to use amazon-cognito-identity-js and per the the table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages I wrote

(ns presentation.cognito.auth
  (:require ["amazon-cognito-identity-js" :refer (CognitoUserPool)]))
but whenever i try to use CognitoUserPool it says its an undeclared var

FlavaDave23:03:19

I also tried

(ns presentation.cognito.auth
  (:require ["amazon-cognito-identity-js$default" :as CognitoUserPool]))
but that didnt work either

Drew Verlee02:03:36

Can you share the js equivalent your working from? I always have to just pattern match from what I'm given to what's on that table.

thheller21:03:43

likely is

(ns presentation.cognito.auth
  (:require ["amazon-cognito-identity-js$default" :refer (CognitoUserPool)]))

thheller21:03:55

note not :as since CognitoUserPool is not the default export

thheller21:03:32

note that the docs have a section on how to figure this out just below the examples

thheller21:03:17

that should probably be more prominent but just at the end of that section

FlavaDave21:03:34

hmmm i changed it to your suggestion and get

:shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-compile, :input {:code "(ns presentation.cognito.auth\n  (:require [\"amazon-cognito-identity-js$default\" :refer (CognitoUserPool) ]))", :ns presentation.cognito.auth, :repl true}, :include-init false, :call-id 7, :from 10}}
StackOverflowError 
        shadow.build.npm/find-resource (npm.clj:726)
when i try to evaluate the namespace

FlavaDave21:03:33

iā€™ll read those docs more and try an figure it out

kardan05:03:34

I have this in a toy project (but, should work) (ns ā€¦ (:require [ā€œamazon-cognito-identity-jsā€ :refer [AuthenticationDetails CognitoUserPool CognitoUserAttribute CognitoUser]] ))

thheller06:03:48

@UF41YH1CM which shadow-cljs version do you use? the stackoverflow was a bug in 2.17.0 so upgrade if you use that

FlavaDave20:03:17

ahh yes i made the switch to 2.17.8 and it works perfectly now!