nextjournal

seancorfield 2021-12-09T05:46:39.207400Z

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?

mkvlr 2021-12-09T06:09:28.207800Z

that is indeed the point of the watcher.

mkvlr 2021-12-09T06:10:59.208700Z

did you use this serve! call in the demo project? https://github.com/nextjournal/clerk-demo/blob/main/dev/user.clj#L9

seancorfield 2021-12-09T06:11:46.210Z

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.

mkvlr 2021-12-09T06:12:42.211Z

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

seancorfield 2021-12-09T06:12:49.211300Z

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

mkvlr 2021-12-09T06:13:28.212200Z

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

mkvlr 2021-12-09T06:13:57.212600Z

you're on windows correct?

seancorfield 2021-12-09T06:14:54.213300Z

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

1
mkvlr 2021-12-09T06:15:24.214100Z

huh ok

mkvlr 2021-12-09T06:17:23.215700Z

thanks for letting us know, this is good info before I release an update πŸ™ƒ

seancorfield 2021-12-09T06:26:14.215900Z

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.

mkvlr 2021-12-09T06:27:30.217100Z

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

seancorfield 2021-12-09T06:27:32.217300Z

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.

mkvlr 2021-12-09T06:28:13.218400Z

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

seancorfield 2021-12-09T06:28:42.218600Z

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

seancorfield 2021-12-09T06:29:39.218800Z

Yes, a JS error:

πŸ‘ 1
mkvlr 2021-12-09T06:30:58.220Z

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

seancorfield 2021-12-09T06:31:40.220500Z

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

seancorfield 2021-12-09T06:32:49.221100Z

mkvlr 2021-12-09T06:32:56.221700Z

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

seancorfield 2021-12-09T06:33:26.221900Z

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

seancorfield 2021-12-09T06:34:22.222100Z

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

mkvlr 2021-12-09T06:36:08.222700Z

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

seancorfield 2021-12-09T06:38:39.222900Z

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
mkvlr 2021-12-09T07:25:03.223200Z

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

mkvlr 2021-12-09T07:25:22.223400Z

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

2021-12-09T10:47:04.224400Z

@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 πŸ™‚

respatialized 2021-12-09T14:16:41.228Z

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.

mkvlr 2021-12-09T15:06:46.228200Z

huh

mkvlr 2021-12-09T15:07:01.228400Z

@afoltzm also with a js error?

respatialized 2021-12-09T18:23:34.232600Z

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

mkvlr 2021-12-09T13:34:54.225400Z

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

2021-12-09T14:10:35.227800Z

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?

emilaasa 2021-12-17T16:21:23.266500Z

That would be sweet. And writing blog posts! πŸ™‚

mkvlr 2021-12-09T15:24:30.228600Z

yes! Something I’d like to see as well

seancorfield 2021-12-09T17:24:17.229600Z

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

seancorfield 2021-12-09T17:25:55.231300Z

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.

mkvlr 2021-12-13T08:01:47.245200Z

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

mkvlr 2021-12-13T09:17:25.245500Z

https://github.com/nextjournal/clerk-demo is bumped as well

seancorfield 2021-12-13T17:47:27.247900Z

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

πŸ™ 1
seancorfield 2021-12-14T00:06:50.248600Z

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

seancorfield 2021-12-14T00:08:05.248800Z

index.md auto-renders for me now, for the first time πŸ™‚

seancorfield 2021-12-14T00:08:34.249Z

Every file, even the previously-broken introduction.clj file πŸ™‚

mkvlr 2021-12-10T12:06:28.243600Z

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

mkvlr 2021-12-09T18:29:16.232800Z

whoops, pushed a fix

mkvlr 2021-12-09T18:29:51.233Z

actually in a sec

mkvlr 2021-12-09T18:32:04.233200Z

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

seancorfield 2021-12-09T18:53:00.233400Z

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

seancorfield 2021-12-09T18:53:37.233600Z

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

seancorfield 2021-12-09T18:54:41.233800Z

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

mkvlr 2021-12-09T19:05:01.234900Z

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

mkvlr 2021-12-09T19:09:48.235500Z

guess I should setup a VM

mkvlr 2021-12-09T19:10:39.236200Z

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

seancorfield 2021-12-09T19:34:24.236500Z

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

seancorfield 2021-12-09T19:36:10.236700Z

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

seancorfield 2021-12-09T19:40:36.236900Z

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.

seancorfield 2021-12-09T19:42:08.237100Z

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

seancorfield 2021-12-09T19:43:26.237300Z

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

mkvlr 2021-12-14T14:59:28.255200Z

thanks a lot for trying this again!

seancorfield 2021-12-09T17:27:25.232200Z

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.

seancorfield 2021-12-09T17:28:07.232500Z

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