cljdoc

lassemaatta 2024-12-23T10:48:26.072699Z

Are there any examples on how to locally run cljdoc on an unpublished leiningen project? I seem to have some trouble getting the local dockerized cljdoc web service to serve my project, most likely some silly user error on my part.

✅ 1
lread 2024-12-28T22:52:51.066059Z

Hiya @lasse.olavi.maatta it should be good now. Fixed docs & the bug I introduced. See https://github.com/cljdoc/cljdoc/pull/959#issuecomment-2564490431 for cmds I tested with. Note that the above server launch is changed to include m2 repo volume:

docker run --rm \                                                                                                                                                   
  --publish 8000:8000 \
  --volume "$HOME/.m2:/root/.m2" \
  --volume ./.cljdoc-preview:/app/data \
  --platform linux/amd64 \
  cljdoc/cljdoc

❤️ 2
lread 2024-12-28T22:53:34.822069Z

Oh and also: thanks for raising the problem!

lassemaatta 2024-12-23T10:48:57.117759Z

As per the instructions, I got the local cljdoc website running with docker within WSL

lassemaatta 2024-12-23T10:50:26.922129Z

This is what happens when I try to ingest my project in a separate terminal:

lassemaatta@DesktopPc:~/personal/murmeli$ docker run --rm --volume $(pwd):/repo-to-import --volume "$HOME/.m2:/root/.m2" --volume ./.cljdoc-preview:/app/data --platform linux/amd64 --entrypoint clojure cljdoc/cljdoc -Sforce -M:cli ingest --project murmeli/murmeli --version 0.1.0-SNAPSHOT --git /repo-to-import --rev $(git rev-parse HEAD)
INFO [2024-12-23 10:45:59,798] main - cljdoc.server.system Starting :cljdoc/build-tracker
INFO [2024-12-23 10:45:59,799] main - cljdoc.server.system Starting :cljdoc/storage
INFO [2024-12-23 10:45:59,800] main - cljdoc.server.system Starting :cljdoc/analysis-service
INFO [2024-12-23 10:45:59,922] clojure-agent-send-off-pool-0 - cljdoc.analysis.git Cloning Git repo from /repo-to-import
INFO [2024-12-23 10:46:06,210] clojure-agent-send-off-pool-0 - cljdoc.analysis.git Analyzing git repo at revision: 70ebcefb0fc5791bd0ce8ab91c8a9e54202ccd54
INFO [2024-12-23 10:46:06,226] clojure-agent-send-off-pool-0 - cljdoc.server.ingest Importing Articles from /repo-to-import
INFO [2024-12-23 10:46:06,252] clojure-agent-send-off-pool-0 - cljdoc.analysis.service Starting local analysis for murmeli/murmeli 0.1.0-SNAPSHOT /root/.m2/repository/murmeli/murmeli/0.1.0-SNAPSHOT/murmeli-0.1.0-SNAPSHOT.jar
INFO [2024-12-23 10:46:14,518] clojure-agent-send-off-pool-0 - cljdoc.analysis.service Got file from Local AnalysisService /tmp/cljdoc/analysis-out/cljdoc-analysis-edn/murmeli/murmeli/0.1.0-SNAPSHOT/cljdoc-analysis.edn
INFO [2024-12-23 10:46:14,534] clojure-agent-send-off-pool-0 - cljdoc.server.ingest Verifying cljdoc analysis edn contents against spec
INFO [2024-12-23 10:46:14,534] clojure-agent-send-off-pool-0 - cljdoc.server.ingest Importing API into database murmeli 0.1.0-SNAPSHOT
INFO [2024-12-23 10:46:14,538] clojure-agent-send-off-pool-0 - cljdoc.storage.sqlite-impl version-id 1

lassemaatta 2024-12-23T10:51:22.147349Z

It seems to be doing something but no idea if the above output is what it should look like or not. In any case, the cljdoc server has no idea about my project

martinklepsch 2024-12-23T10:53:04.227509Z

It looks like it's working fine! How did you diagnose "the cljdoc server has no idea about my project"

martinklepsch 2024-12-23T10:53:15.409859Z

are you using the search?

martinklepsch 2024-12-23T10:53:49.142429Z

try visiting /d/murmeli

lassemaatta 2024-12-23T10:53:54.414009Z

yeah, the search returns all sorts of libraries but not that murmeli project. Also, just returns a "404 - Library not found" error page

lassemaatta 2024-12-23T10:55:03.212779Z

the cljdoc-preview directory contains

lassemaatta@DesktopPc:~/personal/murmeli/.cljdoc-preview$ ll
total 164
drwxr-xr-x  3 root        root          4096 Dec 23 12:46 ./
drwxr-xr-x 11 lassemaatta lassemaatta   4096 Dec 23 12:45 ../
-rw-r--r--  1 root        root        151552 Dec 23 12:46 cljdoc.db.sqlite
drwxr-xr-x  2 root        root          4096 Dec 23 12:22 heapdumps/

lassemaatta 2024-12-23T10:57:08.470069Z

I'm sure the problem is some silly typo somewhere, it took me like a dozen tries to get the docker commands working 🙂

martinklepsch 2024-12-23T10:58:17.925859Z

Does /d/murmeli also yield nothing?

lassemaatta 2024-12-23T10:59:08.987409Z

fyi: I start the server with

lassemaatta@DesktopPc:~/personal/murmeli$ docker run --rm --publish 8000:8000 --volume ./.cljdoc-preview:/app/data --platform linux/amd64 cljdoc/cljdoc
so I assume the /app/data ought to be the same directory

lassemaatta 2024-12-23T10:59:45.763849Z

> Does /d/murmeli also yield nothing? yeah, I get the same error

martinklepsch 2024-12-23T11:00:45.154099Z

Can you try inspecting the sqlite db if it has contents? (you can use /schema to understand the table structure, the versions table should have your project)

lassemaatta 2024-12-23T11:03:54.210059Z

the sqlite looks ok, using emacs to browse it. I can see a single build for the project, the namespaces are listed fine and the versions table lists a single version

lassemaatta 2024-12-23T11:04:59.334889Z

Not sure if this is relevant, but when I run the ingest tool, there's no logging happening in the cljdoc webserver output. Should there be something logged when a library is ingested?

lassemaatta 2024-12-23T11:14:00.404019Z

Interesting. I stopped the webserver, removed the .cljdoc-preview directory and started the server again. The server claimed to run the ragtime migrations, but the .cljdoc-preview contained only that heapdumps directory. Once I ran the ingest tool it also first reported that it ran the migrations before analyzing the code. Afterwards, the .cljdoc-preview contained the sqlite file (which listed the migrations within). Is it possible, that the server is reading a different sqlite file and it's ignoring the one with only my project inside it?

martinklepsch 2024-12-23T11:18:03.059609Z

> there's no logging happening in the cljdoc webserver output that is correct, I think the ingest tool runs directly against the SQLite db if I remember correctly

lassemaatta 2024-12-23T11:18:32.558989Z

should the sqlite db contain only my project or all the projects known to cljdoc?

martinklepsch 2024-12-23T11:18:44.171779Z

only yours when you run it locally

lassemaatta 2024-12-23T11:19:47.823239Z

ok, so I suppose there's another db within the webapp and there's some merging involved when looking at local projects

martinklepsch 2024-12-23T11:20:49.517279Z

there's only one DB but the search runs against a lucene index that is built from remote APIs (clojars+maven) to support searching for projects that have no builds yet

lassemaatta 2024-12-23T11:21:23.586669Z

ok. I wonder what that loggin related to db migrations was when the server was starting 🤔

martinklepsch 2024-12-23T11:21:56.996069Z

it definitely seems like the web app and the ingest tool run against different databases, could you share both commands you use for starting the web app and the ingest command?

martinklepsch 2024-12-23T11:22:24.145409Z

one thing to try is also finding a project via search and building it in the web app, when everything is done right the project data should show up in the DB

lassemaatta 2024-12-23T11:22:33.269699Z

starting the server (after recreating an empty .cljdoc-preview directory):

lassemaatta@DesktopPc:~/personal/murmeli$ docker run --rm --publish 8000:8000 --volume ./.cljdoc-preview:/app/data --platform linux/amd64 cljdoc/cljdoc
Preparing heap dump dir
- will save heap dump on out of memory error to: /app/data/heapdumps/heapdump.hprof
Launching cljdoc server
VM settings:
    Min. Heap Size: 1.00G
    Max. Heap Size: 1.00G
    Using VM: OpenJDK 64-Bit Server VM

INFO [2024-12-23 11:00:50,628] main - cljdoc.server.system Starting :cljdoc/analysis-service
INFO [2024-12-23 11:00:50,721] main - cljdoc.server.system Migrating :up 001-create-builds-table
INFO [2024-12-23 11:00:50,743] main - cljdoc.server.system Migrating :up 002-create-releases-table
INFO [2024-12-23 11:00:50,762] main - cljdoc.server.system Migrating :up 003-add-api-git-columns-to-builds
INFO [2024-12-23 11:00:50,799] main - cljdoc.server.system Migrating :up 004-add-grimoire-style-tables
INFO [2024-12-23 11:00:50,838] main - cljdoc.server.system Migrating :up 005-add-analyzer-version-column-to-builds
INFO [2024-12-23 11:00:50,858] main - cljdoc.server.system Migrating :up 006-add-namespaces-count-column-to-builds
INFO [2024-12-23 11:00:50,886] main - cljdoc.server.system Migrating :up 007-builds-index
INFO [2024-12-23 11:00:50,906] main - cljdoc.server.system Migrating :up 008-create-stats-table
INFO [2024-12-23 11:00:50,925] main - cljdoc.server.system Migrating :up 009-add-error-info-column-to-builds
INFO [2024-12-23 11:00:50,944] main - cljdoc.server.system Migrating :up 010_convert_builds_error_info_from_exception_to_data
INFO [2024-12-23 11:00:50,948] main - migrations.010-convert-builds-error-info-from-exception-to-data rows to udpate: 0
INFO [2024-12-23 11:00:50,968] main - cljdoc.server.system Migrating :up 011-adjust-clojars-stats
INFO [2024-12-23 11:00:50,996] main - cljdoc.server.system Migrating :up 012-add-retry-count-to-releases
INFO [2024-12-23 11:00:51,016] main - cljdoc.server.system Migrating :up 013-remove-duplicate-queued-releases
INFO [2024-12-23 11:00:51,027] main - cljdoc.server.system Starting :cljdoc/build-tracker
INFO [2024-12-23 11:00:51,040] main - cljdoc.server.system Starting :cljdoc/tea-time
INFO [2024-12-23 11:00:51,041] main - cljdoc.server.clojars-stats Starting :cljdoc/clojars-stats
INFO [2024-12-23 11:00:51,045] main - cljdoc.server.db-backup Database backup disable, skipping  :cljdoc/db-backup
INFO [2024-12-23 11:00:51,045] main - cljdoc.server.metrics-logger Starting :cljdoc/metrics-logger
INFO [2024-12-23 11:00:51,046] main - cljdoc.server.search.api Starting :cljdoc/searcher
INFO [2024-12-23 11:00:51,047] Tea-Time 2 - cljdoc.server.metrics-logger mem-stats {:heap-used 163548416, :heap-committed 1073741824, :heap-max 1073741824, :non-heap-used 208384160, :non-heap-committed 253034496}

lassemaatta 2024-12-23T11:22:52.620309Z

running the ingest tool

lassemaatta@DesktopPc:~/personal/murmeli$ docker run --rm --volume $(pwd):/repo-to-import --volume "$HOME/.m2:/root/.m2" --volume ./.cljdoc-preview:/app/data --platform linux/amd64 --entrypoint clojure cljdoc/cljdoc -Sforce -M:cli ingest --project murmeli/murmeli --version 0.1.0-SNAPSHOT --git /repo-to-import --rev $(git rev-parse HEAD)
INFO [2024-12-23 11:01:57,363] main - cljdoc.server.system Migrating :up 001-create-builds-table
INFO [2024-12-23 11:01:57,385] main - cljdoc.server.system Migrating :up 002-create-releases-table
INFO [2024-12-23 11:01:57,405] main - cljdoc.server.system Migrating :up 003-add-api-git-columns-to-builds
INFO [2024-12-23 11:01:57,456] main - cljdoc.server.system Migrating :up 004-add-grimoire-style-tables
INFO [2024-12-23 11:01:57,494] main - cljdoc.server.system Migrating :up 005-add-analyzer-version-column-to-builds
INFO [2024-12-23 11:01:57,513] main - cljdoc.server.system Migrating :up 006-add-namespaces-count-column-to-builds
INFO [2024-12-23 11:01:57,532] main - cljdoc.server.system Migrating :up 007-builds-index
INFO [2024-12-23 11:01:57,551] main - cljdoc.server.system Migrating :up 008-create-stats-table
INFO [2024-12-23 11:01:57,570] main - cljdoc.server.system Migrating :up 009-add-error-info-column-to-builds
INFO [2024-12-23 11:01:57,589] main - cljdoc.server.system Migrating :up 010_convert_builds_error_info_from_exception_to_data
INFO [2024-12-23 11:01:57,593] main - migrations.010-convert-builds-error-info-from-exception-to-data rows to udpate: 0
INFO [2024-12-23 11:01:57,612] main - cljdoc.server.system Migrating :up 011-adjust-clojars-stats
INFO [2024-12-23 11:01:57,651] main - cljdoc.server.system Migrating :up 012-add-retry-count-to-releases
INFO [2024-12-23 11:01:57,670] main - cljdoc.server.system Migrating :up 013-remove-duplicate-queued-releases
INFO [2024-12-23 11:01:57,681] main - cljdoc.server.system Starting :cljdoc/build-tracker
INFO [2024-12-23 11:01:57,682] main - cljdoc.server.system Starting :cljdoc/storage
INFO [2024-12-23 11:01:57,682] main - cljdoc.server.system Starting :cljdoc/analysis-service
INFO [2024-12-23 11:01:57,827] clojure-agent-send-off-pool-0 - cljdoc.analysis.git Cloning Git repo from /repo-to-import
INFO [2024-12-23 11:02:04,150] clojure-agent-send-off-pool-0 - cljdoc.analysis.git Analyzing git repo at revision: 70ebcefb0fc5791bd0ce8ab91c8a9e54202ccd54
INFO [2024-12-23 11:02:04,166] clojure-agent-send-off-pool-0 - cljdoc.server.ingest Importing Articles from /repo-to-import
INFO [2024-12-23 11:02:04,191] clojure-agent-send-off-pool-0 - cljdoc.analysis.service Starting local analysis for murmeli/murmeli 0.1.0-SNAPSHOT /root/.m2/repository/murmeli/murmeli/0.1.0-SNAPSHOT/murmeli-0.1.0-SNAPSHOT.jar
INFO [2024-12-23 11:02:13,932] clojure-agent-send-off-pool-0 - cljdoc.analysis.service Got file from Local AnalysisService /tmp/cljdoc/analysis-out/cljdoc-analysis-edn/murmeli/murmeli/0.1.0-SNAPSHOT/cljdoc-analysis.edn
INFO [2024-12-23 11:02:13,951] clojure-agent-send-off-pool-0 - cljdoc.server.ingest Verifying cljdoc analysis edn contents against spec
INFO [2024-12-23 11:02:13,951] clojure-agent-send-off-pool-0 - cljdoc.server.ingest Importing API into database murmeli 0.1.0-SNAPSHOT
INFO [2024-12-23 11:02:13,955] clojure-agent-send-off-pool-0 - cljdoc.storage.sqlite-impl version-id 1

lassemaatta 2024-12-23T11:26:01.696769Z

I manually built core.async, it succeeded but the local sqlite db still only contains data about my project

martinklepsch 2024-12-23T11:32:00.963949Z

If you don't run the ingest, delete the .cljdoc-preview directory and then run the server the DB doesn't show up at all right?

lassemaatta 2024-12-23T11:32:07.240929Z

I looked within the running container and I suppose /var/cljdoc/cljdoc.db.sqlite is the other database

lassemaatta 2024-12-23T11:32:10.986469Z

yeah, correct

martinklepsch 2024-12-23T11:33:36.628229Z

interesting, what happens if you use /var/cljdoc over /app/data ?

martinklepsch 2024-12-23T11:35:59.684349Z

I'm not sure the /app/data thing is right, I can't find any references of it in the codebase but can find some for /var/cljdoc

martinklepsch 2024-12-23T11:43:12.126299Z

Give this a try and see

docker run --rm --publish 8000:8000 --volume ./.cljdoc-preview:/var/cljdoc --platform linux/amd64 cljdoc/cljdoc

lassemaatta 2024-12-23T11:49:58.214579Z

It doesn't seem to help. It injects my project to the sqlite db under /var/cljdoc. It seems to also contain a lot of stuff in the clojars_stats table. But the end result is that the server still does not find my project

lassemaatta 2024-12-23T11:51:52.614729Z

I think I'll need to return later to debug this, thanks a lot for the help 🙂

martinklepsch 2024-12-23T12:08:42.148499Z

Sounds good, we'll get back to this some time :) To summarize: You ran the server with

docker run --rm 
           --publish 8000:8000 
           --volume ./.cljdoc-preview:/app/data 
           --platform linux/amd64 
           cljdoc/cljdoc
You ingested your project with
docker run --rm 
           --volume $(pwd):/repo-to-import 
           --volume "$HOME/.m2:/root/.m2" 
           --volume ./.cljdoc-preview:/app/data 
           --platform linux/amd64 
           --entrypoint clojure cljdoc/cljdoc -Sforce -M:cli ingest --project murmeli/murmeli --version 0.1.0-SNAPSHOT --git /repo-to-import --rev $(git rev-parse HEAD)
Observations: 1. Migrations were seemingly ran in each of the above commands 2. The ingest succeeded but visiting /d/murmeli yielded no results 3. The SQLite DB in ./.cljdoc-preview contained the ingested project 4. It looks like both commands wrote to different SQLite db files

lread 2024-12-23T17:19:56.177939Z

I'll read up on the above sometime soon and see what I can see. I've never tested this on WSL... only macOS and Linux. I can try to preview on Linux and see what happens.

lassemaatta 2024-12-23T17:20:57.229269Z

No worries, I’ll happily volunteer as a test subject :)

lassemaatta 2024-12-23T17:21:50.024989Z

I think I’ll test this tomorrow on my mac, just to see if I get different results

lread 2024-12-23T17:22:15.240649Z

I have a bit of time now. I'll give it a go on Linux and report back.

lread 2024-12-23T17:49:08.880289Z

Yeah... I think local preview is currently broken. I can take a look and fix sometime soon.

lread 2024-12-23T17:51:31.500839Z

https://github.com/cljdoc/cljdoc/issues/957

lassemaatta 2024-12-23T17:52:42.072339Z

Don't sweat it, enjoy the holidays 🙂

💯 1
❤️ 1
martinklepsch 2024-12-23T17:55:09.217919Z

Happy holidays to both of you 🫶

❤️ 1
lassemaatta 2024-12-29T12:36:48.088819Z

Great, thanks for fixing it 👍