Fork me on GitHub
#shadow-cljs
<
2018-08-12
>
yqrashawn02:08:40

Hi guys. I’m new to clojure and shadow-cljs. I encountered this error when shadow-cljs watch app

yqrashawn02:08:44

shadow-cljs - config: /Users/yqrashawn/workspace/HOME/right-site/shadow-cljs.edn  cli version: 2.4.33  node: v9.8.0
shadow-cljs - starting ...
Aug 12, 2018 9:54:04 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Aug 12, 2018 9:54:04 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
Exception in thread "main" java.lang.AssertionError: Assert failed: (qualified-symbol? sym)
        at shadow.cljs.devtools.server.nrepl04$middleware_load.invokeStatic(nrepl04.clj:269)
        at shadow.cljs.devtools.server.nrepl04$middleware_load.invoke(nrepl04.clj:269)
        at clojure.core$map$fn__5587.invoke(core.clj:2745)
        at clojure.lang.LazySeq.sval(LazySeq.java:40)
        at clojure.lang.LazySeq.seq(LazySeq.java:49)
        at clojure.lang.RT.seq(RT.java:528)
        at clojure.core$seq__5124.invokeStatic(core.clj:137)
        at clojure.core$filter$fn__5614.invoke(core.clj:2801)
        at clojure.lang.LazySeq.sval(LazySeq.java:40)
        at clojure.lang.LazySeq.seq(LazySeq.java:49)
        at clojure.lang.RT.seq(RT.java:528)
        at clojure.core$seq__5124.invokeStatic(core.clj:137)
        at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:24)
        at clojure.core.protocols$fn__7835.invokeStatic(protocols.clj:75)
        at clojure.core.protocols$fn__7835.invoke(protocols.clj:75)
        at clojure.core.protocols$fn__7781$G__7776__7794.invoke(protocols.clj:13)
        at clojure.core$reduce.invokeStatic(core.clj:6748)
        at clojure.core$into.invokeStatic(core.clj:6815)
        at clojure.core$into.invoke(core.clj:6807)

lilactown02:08:32

is this with a fresh project?

yqrashawn02:08:53

it’s generated by re-frame-template

lilactown02:08:06

can you post your shadow-cljs.edn?

yqrashawn02:08:37

{:nrepl {:port 9898
         :middleware [[cider/piggieback "0.3.5"]]}
 :http {:port 3333
        :host "0.0.0.0"}
 :source-paths ["src/clj" "src/cljs"]
 :dependencies [[org.clojure/clojure "1.8.0"]
                [org.clojure/clojurescript "1.10.238"]
                [reagent "0.7.0"]
                [re-frame "0.10.5"]
                ;; [secretary "1.2.3"]
                [garden "1.3.5"]
                [ns-tracker "0.3.1"]
                [compojure "1.5.0"]
                [bidi "2.1.3"]
                [yogthos/config "0.8"]
                [ring "1.4.0"]
                [re-pressed "0.2.2"]
                [re-frisk "0.5.3"]
                [binaryage/devtools "0.9.10"]
                [day8.re-frame/re-frame-10x "0.3.3"]]

 :builds
 {:app {:target :browser
        :output-dir "resources/public/js/compiled/"
        :asset-path           "js/compiled/out"
        :modules {:main {:entries [right-site.core]}}
        :devtools {:http-root "resources/public"
                   :http-port 3000
                   :http-host "0.0.0.0"
                   :open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]
                   :autoload true}}}}

yqrashawn02:08:10

src
├── clj
│  └── right_site
│     ├── core.clj
│     ├── css.clj
│     ├── handler.clj
│     └── server.clj
└── cljs
   └── right_site
      ├── config.cljs
      ├── core.cljs
      ├── db.cljs
      ├── events.cljs
      ├── home-page
      │  ├── home_page_data.cljs
      │  └── home_page_views.cljs
      ├── login-page
      │  ├── login_page_data.cljs
      │  └── login_page_views.cljs
      ├── routes.cljs
      ├── subs.cljs
      └── views.cljs

yqrashawn02:08:51

I just removed the :middleware [[cider/piggieback “0.3.5”]] and it works.

yqrashawn02:08:04

Is the middleware syntax wrong?

lilactown02:08:07

yeah that’s what I was going to try next

lilactown02:08:44

it might be a couple different things

lilactown02:08:46

I think it’s unnecessary, since shadow-cljs provides it’s own version of piggieback

lilactown02:08:36

not exactly sure why it’s throwing, but you should be fine to develop without it as a dependency

yqrashawn02:08:09

Thanks. I’ll try.

yqrashawn02:08:30

I created a issue in case someone else stuck with the same question. https://github.com/thheller/shadow-cljs/issues/366

thheller07:08:22

@namy.19 thanks for the report. I'll probably just filter out manually specified piggieback middleware in the future.

urbanslug08:08:37

Anyone know how to kill the nrepl server?

urbanslug08:08:18

When I try to start the repl in emacs I keep getting an error

error in process sentinel: Could not start nREPL server: shadow-cljs - config: .../shadow-cljs.edn  cli version: 2.4.11  node: v10.8.0
shadow-cljs - connected to server
server already running

thheller08:08:05

@urbanslug shadow-cljs stop should stop it

urbanslug08:08:13

emacs still gives the error 😬

urbanslug08:08:08

btw @thheller when I put the constants in my html they tended to get lost on files changes

urbanslug08:08:17

When I modified cljs files

thheller08:08:46

do you reset your state on reload?

urbanslug08:08:02

I don't think I do. I don't have code that resets the app-state no

thheller08:08:23

do you have a (defonce app-state ..) or (def app-state ..)?

urbanslug08:08:22

(defonce app-state (r/atom default-app-state))
where default-app-state is an object

urbanslug08:08:50

but I transact this app state in my init to add the runtime args

thheller08:08:25

and you only call init once? its not a hook or anything?

thheller08:08:53

I don't know your app setup but if state in the atom gets lost that on your side of things

thheller08:08:58

shadow-cljs doesn't mess with your atoms

urbanslug09:08:59

Yes I only call init once. I will investigate

Jon18:08:20

I think now I have trouble download that jar file from GitHub,

thheller18:08:08

yeah sorry about that. still trying to figure out how to deal with this.

Jon18:08:11

not even managed to do it with proxychains, although proxychains4 wget ....jar worked.

thheller18:08:23

I really want to get rid of the mandatory shadow-cljs-jar dependency

Jon18:08:35

can I download it manually?

Jon18:08:57

or redirect the link to another domain where I can prepare that jar file?

thheller18:08:02

yes, you can put it into ~/.shadow-cljs/shadow-cljs-launcher-2.0.0.jar manually

Jon18:08:11

Downloaded and it's running

Jon18:08:05

Does shadow-cljs make use of proxychains?

thheller18:08:19

no. I don't even know what that is 😛

thheller18:08:34

its just doing a simple download using the node https package

Jon18:08:22

I need this proxy to access Google

Jon18:08:52

and download files from GitHub, which has amazon addresses

Jon18:08:45

of socks5 specifically. But in command line tools, proxychains is required.

thheller18:08:48

so my current thought is to continue providing the shadow-cljs-jar package but not depend on it

thheller18:08:54

so you install it manually

thheller18:08:17

would that work? annoying but npm works right?

thheller18:08:42

just haven't figured out how to ensure the correct version numbers with this way

Jon18:08:17

install it manually means download and put it in ~/.shadow-cljs/?

thheller18:08:38

no you npm install shadow-cljs shadow-cljs-jar

thheller18:08:09

previously shadow-cljs just depended on shadow-cljs-jar but I want to get rid of that extra npm download since it mostly wasted

Jon18:08:31

it's okay in my case. they are peerDependencies.

thheller18:08:37

only considering adding it back for chinese users as an alternate to the github download if that so unreliable

Jon18:08:12

unreliable, 😄

thheller18:08:49

chinese internet is a bit scary

thheller18:08:31

hmm I could create a shadow-cljs-standalone package which downloads shadow-cljs and the launcher (via npm)

Jon18:08:31

I think I can't finish running new version tonight.. going to bed, bye~

thheller18:08:59

well you don't have to upgrade, nothing new in it besides the launcher

thheller18:08:12

oh there is actually one new thing. @currentoor the change to :npm-script is in 2.5.0 so it should be now possible to do the raspberry pi development we talked about.

👍 4
currentoor18:08:09

Thank you so much!

currentoor18:08:31

I’ll try later today

thheller18:08:58

you'll probably need to set :output-to "out/script.js" :output-dir "out/something". by default :output-dir is set to something that might not be reachable on the pi

currentoor20:08:03

so i made a directory on my laptop pi and mounted the raspberry pi’s filesystem on it

currentoor20:08:27

set these values

:output-dir "pi/nodetest/ucv_tcs"
                :output-to  "pi/nodetest/main.js"

currentoor20:08:52

but when i try to run the compiled file i get

Error: ENOENT: no such file or directory, open '/Users/currentoor/src/ucv/pi/nodetest/ucv_tcs/cljs-runtime/goog.debug.error.js'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at global.SHADOW_IMPORT (/home/pi/nodetest/main.js:46:15)
    at /home/pi/nodetest/main.js:3005:1
    at Object.<anonymous> (/home/pi/nodetest/main.js:3200:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

currentoor20:08:09

oh wait i forgot to update shadow-cljs

currentoor20:08:12

:man-facepalming:

currentoor20:08:38

yeah @thheller i’m still getting that error even after updating

currentoor20:08:13

i see this in the compiled out put

currentoor20:08:16

var SHADOW_IMPORT_PATH = "/Users/currentoor/src/ucv/pi/nodetest/ucv_tcs/cljs-runtime";

currentoor20:08:45

maybe i misunderstood what you said earlier, i thought this was no longer going to be an absolute path?

currentoor20:08:55

if i manually edit that variable to be a relative path it works, except the repl doesn’t seem to connect

currentoor20:08:09

REPL client error { Error: connect ECONNREFUSED 127.0.0.1:9630
    at Object._errnoException (util.js:992:11)
    at _exceptionWithHostPort (util.js:1014:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 9630 }
REPL client disconnected

currentoor20:08:49

not a caching thing, i tried lein clean

thheller20:08:29

uhm that is definitely not the upgraded code

thheller20:08:05

should be something starting with var SHADOW_IMPORT_PATH = __dirname +

thheller20:08:29

the host thing you just need to configure

thheller20:08:39

:devtools {:devtools-url "http://<ip-of-your-machine>:9630"}

currentoor20:08:06

hmm, i nuked node_modules and did an npm install

currentoor20:08:26

these lines are printed when i start shadow-cljs

thheller20:08:30

you said lein clean? are you using lein?

currentoor20:08:31

shadow-cljs - config: /Users/currentoor/src/ucv/shadow-cljs.edn  cli version: 2.5.0  node: v10.4.1
shadow-cljs - running: lein with-profile cljs run -m shadow.cljs.devtools.cli --npm watch tcs

thheller20:08:47

do you have a shadow-cljs version in project.clj?

thheller20:08:05

look further down in the printed messages

thheller20:08:12

the versions on top are the npm package versions

currentoor20:08:24

yes that was it

currentoor20:08:27

i forgot project.clj had it too

currentoor20:08:39

that worked beautifully!

currentoor20:08:41

thanks again!

👍 4
Jon18:08:20

=>> yarn watch
yarn run v1.9.4
$ shadow-cljs watch client
shadow-cljs - config: /Users/chen/repo/mvc-works/calcit-workflow/shadow-cljs.edn  cli version: 2.5.0  node: v10.8.0
shadow-cljs - starting 2.5.0 with launcher 2.0.0 ...
Downloading: thheller/shadow-cljs/2.5.0/shadow-cljs-2.5.0-aot.jar from 
Downloading: org/clojure/clojurescript/1.10.339/clojurescript-1.10.339-slim.jar from 
Downloading: com/google/javascript/closure-compiler-externs/v20180805/closure-compiler-externs-v20180805.jar from 
Downloading: com/google/javascript/closure-compiler-unshaded/v20180805/closure-compiler-unshaded-v20180805.jar from 
Downloading: com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar from 
Aug 13, 2018 2:34:44 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Aug 13, 2018 2:34:44 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :client available at 
shadow-cljs - server version: 2.5.0
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 53885
shadow-cljs - nREPL server started on port 53887
shadow-cljs - watching build :client
[:client] Configuring build.
[:client] Compiling ...
[:client] Build completed. (198 files, 98 compiled, 0 warnings, 32.43s)

Jon18:08:30

finally.

Jon18:08:44

it was downloading jar files, took long time.

Jon18:08:55

{:source-paths ["src" "cli"]
 :mirrors {"central" {:name "central"
                       :url ""}}

thheller18:08:12

oh shit .. I don't think :mirrors works anymore

Jon18:08:13

I added mirrors, it was expected to use aliyun

thheller18:08:30

totally forgot to check if tools.deps actually supports that

Jon18:08:35

so it's a bug? 😮

Jon18:08:06

okay. :thinking_face:

Jon18:08:14

I'm going to bed. too late. bye.

hlolli19:08:19

does shadow-cljs offer any way to run a script before compilation. What I'm looking to do, is compiling for browser where I sed replace a variable with base64 of a .wasm file but compile to node without that replace. It would be nice to avoid having two copies of that emscripten bindings file, as one would include few mb string and the other not.

hlolli19:08:12

So that the script would replace in the "stream" but not the file itself.

hlolli19:08:40

ah I see, I think that would be enough!

thheller19:08:17

wont base64 make the file huge? isn't it better to download it independently via xhr?

hlolli20:08:47

yes it makes a very huge file. But the mechanism in the wasm bindings makes it bit tedious to bundle the app, it's a window.fetch and needs cors to work right, as well as not working with file:// protocol. As I'm makeing a library that mostly non-programmers use, just one script tag makes it easier for everyone.

hlolli20:08:22

but in node, it doesn't make sense to do it, and actually overflows the heap.

thheller20:08:24

cors to download a text file?

thheller20:08:06

ah nvm. probably not downloading from the same domain then