Fork me on GitHub
#nextjournal
<
2021-12-09
>
seancorfield05:12:39

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?

mkvlr06:12:28

that is indeed the point of the watcher.

seancorfield06:12:46

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.

mkvlr06:12:42

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

seancorfield06:12:49

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

mkvlr06:12:28

ok, I'll check as soon as I'm at my computer

mkvlr06:12:57

you're on windows correct?

seancorfield06:12:54

Tried it on both macOS and Windows/WSL with the same result.

1
mkvlr06:12:23

thanks for letting us know, this is good info before I release an update 🙃

seancorfield06:12:14

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.

mkvlr06:12:30

and it works via show! so we can be sure it's not just taking a while to compute?

seancorfield06:12:32

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.

mkvlr06:12:13

ok, think that hints at a js error, do you see one in the browser console?

seancorfield06:12:42

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...

seancorfield06:12:39

Yes, a JS error:

👍 1
mkvlr06:12:58

that's at the end of the introduction notebook, I'll fix this in a bit

seancorfield06:12:40

If I comment out that form, it loads, but I still get an error in the console...

mkvlr06:12:56

and need to make Clerk surface those errors instead of failing silently

seancorfield06:12:26

I tried editing index.md from the root of the project and that does not trigger Clerk to re-evaluate it.

seancorfield06:12:22

None of the .md files get automatically evaluated & rendered. Just the .clj files. Is that expected?

mkvlr06:12:08

nope, I'd expect that to also work in fact

seancorfield06:12:39

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.

🙏 1
mkvlr07:12:03

so this works fine here for me, using 60c98a7edc2504134547aa96f829c955bc891906 of the clerk-demo

mkvlr07:12:22

could you try if (clerk/clear-cache!) helps if you’re already on 60c98a7edc2504134547aa96f829c955bc891906?

jackrusher10:12:04

@U04V70XH6 I'm hoping that after we provide more use case examples over the coming weeks you'll start to have ideas for using Clerk 🙂

respatialized14:12:41

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.

mkvlr15:12:01

@UFTRLDZEW also with a js error?

respatialized18:12:34

@mkvlr no JS errors for me, rendering generally tends to work ok

mkvlr13:12:54

anybody here on windows who has a few minutes to test https://github.com/nextjournal/clerk-demo on the latest main?

adwelly14:12:35

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?

mkvlr15:12:30

yes! Something I’d like to see as well

emilaasa16:12:23

That would be sweet. And writing blog posts! 🙂

seancorfield17:12:17

@mkvlr That version no longer even auto-renders the source files that the previous version did.

seancorfield17:12:55

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.

mkvlr18:12:16

whoops, pushed a fix

mkvlr18:12:51

actually in a sec

mkvlr18:12:04

ok pushed, can you please pull & try again, thank you!

seancorfield18:12:00

Nope. Modifying the watched files still doesn't auto-render in the browser.

seancorfield18:12:37

:deps {io.github.nextjournal/clerk        {:git/sha "9cde5ec9ddd2f2e9d0752c7bcc4ff752c996bd04"}
that's from the updated clerk-demo after the pull.

seancorfield18:12:41

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=> 

mkvlr19:12:01

this is on windows but you're saying it also didn't work for you on macOS?

mkvlr19:12:48

guess I should setup a VM

mkvlr19:12:39

sounds like the file watcher lib https://github.com/nextjournal/beholder doesn't work at all for you

seancorfield19:12:24

It works in a scratch project but doesn't work in clerk-demo.

seancorfield19:12:10

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).

seancorfield19:12:36

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.

seancorfield19:12:08

At least, it works for .clj files. It doesn't seem to eval/render .md files without an explicit call to show!

seancorfield19:12:26

(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)

mkvlr12:12:28

that's really strange given that beholder didn't change, will dig deeper next week, thanks again for your help

mkvlr08:12:47

ok, we know what’s going on now (yay open source!): https://github.com/nextjournal/clerk/pull/28

seancorfield17:12:27

Nice. Will give it another try later, once I'm done with work for the day.

🙏 1
seancorfield00:12:50

Confirmed! The demo all works as expected now! Thank you!

seancorfield00:12:05

index.md auto-renders for me now, for the first time 🙂

seancorfield00:12:34

Every file, even the previously-broken introduction.clj file 🙂

mkvlr14:12:28

thanks a lot for trying this again!

seancorfield17:12:25

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.

seancorfield17:12:07

The latest clerk-demo has :deps {io.github.nextjournal/clerk {:git/sha "7c1842bbe18637afc73c9c82efb044e620e3084f"}