The LA Meetup started to look at Clerk tonight and we saw some kind of odd behavior. I started up a REPL in a dummy project, required the nextjournal.clerk namespace and then asked it to serve! watching two folders. In my editor, whenever I saved files in those folders, the browser automatically refreshed to that file and rendered it. I didn't have to call show! at all. That seemed really nice. However, when I tried to do the exact same thing inside the clerk-demo project that I had checked out, that same process did not work -- I had to explicitly call show! to get the browser to update. Another LA Meetup member had that same behavior in the clerk-demo namespace. Which is the expected behavior? I thought the point of the watcher was to auto-reload as each file changed?
that is indeed the point of the watcher.
did you use this serve! call in the demo project? https://github.com/nextjournal/clerk-demo/blob/main/dev/user.clj#L9
Yes, two of us tried that, both manually from a REPL started in clerk-demo and from a REPL-connected editor in the clerk-demo project.
one thing I can think of is that some of the example notebooks (especially sicmutils and semantic) take quite a while to compute the first time
It worked just fine in a standalone project, using both 0.2.214 and the more recent 0.3.something release (whatever is the latest on Clojars). But nothing we tried worked in clerk-demo
ok, I'll check as soon as I'm at my computer
you're on windows correct?
Tried it on both macOS and Windows/WSL with the same result.
huh ok
thanks for letting us know, this is good info before I release an update π
I added a new foobar.clj file in notebooks and that got auto-rendered. Then I modified elements.clj and that auto-rendered. I added example.clj to src and that auto-rendered. But changing index.md or notebooks/introduction.clj does not trigger auto-rendering.
and it works via show! so we can be sure it's not just taking a while to compute?
I see
Clerk evaluated 'notebooks/introduction.clj' in 307.177276ms.
in the REPL but the browser view stays on the previously rendered page -- and if I refresh after saving that file, I get a blank page.ok, think that hints at a js error, do you see one in the browser console?
I just ran this in the REPL and it still don't render the page:
user=> (clerk/show! "notebooks/introduction.clj")
Clerk evaluated 'notebooks/introduction.clj' in 284.240345ms.
nil
So it looks like some pages are broken in terms of rendering? Let me pull up dev tools...Yes, a JS error:
that's at the end of the introduction notebook, I'll fix this in a bit
If I comment out that form, it loads, but I still get an error in the console...
and need to make Clerk surface those errors instead of failing silently
I tried editing index.md from the root of the project and that does not trigger Clerk to re-evaluate it.
None of the .md files get automatically evaluated & rendered. Just the .clj files. Is that expected?
nope, I'd expect that to also work in fact
OK, happy to test the fixes when they drop. I don't think I'm the target audience for Clerk though: I can't understand what I'd use it for at all.
so this works fine here for me, using 60c98a7edc2504134547aa96f829c955bc891906 of the clerk-demo
could you try if (clerk/clear-cache!) helps if youβre already on 60c98a7edc2504134547aa96f829c955bc891906?
@seancorfield I'm hoping that after we provide more use case examples over the coming weeks you'll start to have ideas for using Clerk π
I can confirm that I have also observed this issue when attempting to run a notebook watcher in a Windows directory from WSL. Autorefresh works fine on WSL/Ubuntu paths, but not Windows ones.
huh
@afoltzm also with a js error?
@mkvlr no JS errors for me, rendering generally tends to work ok
anybody here on windows who has a few minutes to test https://github.com/nextjournal/clerk-demo on the latest main?
About to take Clerk out for a third spin (will use the sha above) - and a thought occcurs for some distant date - could there ever be the possibility of generating slides from Clerk?
That would be sweet. And writing blog posts! π
yes! Something Iβd like to see as well
@mkvlr That version no longer even auto-renders the source files that the previous version did.
Here's my REPL session in the latest clerk-demo checkout:
(! 534)-> clojure -M:rebel
Downloading: com/bhauman/rebel-readline/maven-metadata.xml from clojars
DEPRECATED: Libs must be qualified, change clj-time => clj-time/clj-time (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change backtick => backtick/backtick (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change clj-http => clj-http/clj-http (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change clj-time => clj-time/clj-time (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change backtick => backtick/backtick (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change clj-http => clj-http/clj-http (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
[Rebel readline] Type :repl/help for online help info
user=> (require '[nextjournal.clerk :as clerk])
nil
user=> (clerk/serve! {:watch-paths ["notebooks" "src" "index.md"]})
Clerk webserver started on 7777...
Starting new watcher for paths ["notebooks" "src" "index.md"]
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
{:watch-paths ["notebooks" "src" "index.md"]}
user=>
and then I open a browser to localhost:7777 and it just says "Use nextjournal.clerk/show!..." and when I modify files in notebooks or src, they are not auto-rendered.ok, we know whatβs going on now (yay open source!): https://github.com/nextjournal/clerk/pull/28
https://github.com/nextjournal/clerk-demo is bumped as well
Nice. Will give it another try later, once I'm done with work for the day.
Confirmed! The demo all works as expected now! Thank you!
index.md auto-renders for me now, for the first time π
Every file, even the previously-broken introduction.clj file π
that's really strange given that beholder didn't change, will dig deeper next week, thanks again for your help
whoops, pushed a fix
actually in a sec
ok pushed, can you please pull & try again, thank you!
Nope. Modifying the watched files still doesn't auto-render in the browser.
:deps {io.github.nextjournal/clerk {:git/sha "9cde5ec9ddd2f2e9d0752c7bcc4ff752c996bd04"}
that's from the updated clerk-demo after the pull.Just to show that it did checkout that latest version:
(! 536)-> clojure -M:rebel
Checking out: at 9cde5ec9ddd2f2e9d0752c7bcc4ff752c996bd04
DEPRECATED: Libs must be qualified, change clj-time => clj-time/clj-time (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change backtick => backtick/backtick (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change clj-http => clj-http/clj-http (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change clj-time => clj-time/clj-time (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change backtick => backtick/backtick (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
DEPRECATED: Libs must be qualified, change clj-http => clj-http/clj-http (/Users/sean/.gitlibs/libs/jackrusher/mundaneum/84476918ee47b66a2d6128e1a90780e52fd2ae44/deps.edn)
[Rebel readline] Type :repl/help for online help info
user=> (require '[nextjournal.clerk :as clerk])
nil
user=> (clerk/clear-cache!)
:cache-dir/does-not-exist ".cache"
nil
user=> (clerk/serve! {:watch-paths ["notebooks" "src" "index.md"]})
Clerk webserver started on 7777...
Starting new watcher for paths ["notebooks" "src" "index.md"]
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
{:watch-paths ["notebooks" "src" "index.md"]}
user=> this is on windows but you're saying it also didn't work for you on macOS?
guess I should setup a VM
sounds like the file watcher lib https://github.com/nextjournal/beholder doesn't work at all for you
It works in a scratch project but doesn't work in clerk-demo.
And, yes, it's possible that Beholder is problematic. I'm on macOS 10.12 (for reasons). I can try this on Windows/WSL but that means running Google Chrome on WSL which kind of sucks (on macOS, I can run VS Code's Simple Browser and have the browser just as a tab inside my editor).
If I move deps.edn out of the way in clerk-demo and start a REPL using the :mvn/version "RELEASE" it does work, if that helps.
At least, it works for .clj files. It doesn't seem to eval/render .md files without an explicit call to show!
(I also tried the :git/sha version with deps.edn moved out of the way to ensure it wasn't a conflict with another dependency -- no dice... so the released version 0.3.233 works for me but more recent versions do not)
thanks a lot for trying this again!
Just to be sure, I ran (clerk/clear-cache!) in the REPL (which said it deleted the .cache folder) but it didn't make any difference.
The latest clerk-demo has :deps {io.github.nextjournal/clerk {:git/sha "7c1842bbe18637afc73c9c82efb044e620e3084f"}