gnl/playback

failed to require macro-ns "playback.core", it was required by "playback.core", RuntimeException: No such var: server/as-channel

Closed this issue · 4 comments

Tried to add playback to my project as instructed. Removed Debux and explicitly added:

[org.clojure/clojurescript "1.11.132"]
[org.clojure/clojure "1.11.1"]

Still, I'm getting the error:

File: jar:file:/home/german/.m2/repository/com/github/gnl/playback/0.5.4/playback-0.5.4.jar!/playback/core.cljc
failed to require macro-ns "playback.core", it was required by "playback.core"
Error in phase :compile-syntax-check
RuntimeException: No such var: server/as-channel

full-error.txt
shadow-cljs.txt

gnl commented

My guess would be that Portal's reference to server/as-channel here doesn't resolve because something else on your classpath (possibly an older http-kit version) is providing the org.httpkit.server namespace and overriding Portal's dependency there.

Can you check for that and try to create a minimal repro, maybe with a very basic Hello World or template project that uses the same Shadow config, see if you can make it break and then start removing dependencies until it works and you find the culprit.

I found the culprit for compilation error - [figwheel-sidecar "0.5.19"]. After removing it, exception goes away. Thanks for the advice!

I think you should add 2 points to the Quick Start guide:

1. org.clojure/clojurescript and org.clojure/clojure dependencies must be explicitly added to the project.

Without this, running a shadow-cljs project results in the following:
playback kind of works, but a Portal window still doesn't open up on REPL startup. I tried running (playback.core/open-portal!), and it returns:

:repl/exception!
;
; Execution error (TypeError) at (<cljs repl>:1).
; Cannot set properties of null (setting 'onunload')

2. Browsers might block Portal as a pop-up window.

I missed this at first, and thought that playback wasn't working properly.

gnl commented

Glad it's working!

  1. org.clojure/clojurescript and org.clojure/clojure dependencies must be explicitly added to the project.

It's generally understood and implicitly assumed that people will manually add Clojure and ClojureScript as their most essential project dependencies; we don't automatically do this in libraries, because it risks overriding someone's chosen version in unpredictable ways. I will however add a note about the required Clojure version being 1.10+.

  1. Browsers might block Portal as a pop-up window.

That's a good point, I'll add a hint, thanks. I'll leave this issue open until I've updated the README.

gnl commented

I just updated the README.

One final clarifying note on why this happened exactly – usually an older version of a dependency wouldn't automatically override a newer one when using tools.deps, however the older version of http-kit required by figwheel-sidecar uses the simple name http-kit while the newer one required by Portal uses the fully qualified name http-kit/http-kit, so these are effectively two separate artifacts on the classpath providing the same namespaces, which tends to result in chaos.