Open14

2025-09 開発スクラップ 主にLivebookのコード読解

tatotato

はじめに

  • どこかに書いておけば何かの役に立つだろう(?)なメモや、ただのトラブルの供養です。
  • 話題に上げているLivebookバージョンは @version "0.17.0-dev"
  • コード生成AI環境は Claude Opus/Sonnet 4
tatotato

Livebook プラクティスの書き出し ↓

  • data-p-*をHookで使う共通の属性としている
  • assets/js/lib/に共通ライブラリ群
tatotato

Livebook 以前みたときから時間が空いたので手元で試す。
(外から見る分にはdocker起動で良いが遊ぶにあたり)

tatotato

ERROR!!! [Livebook] You must set the environment variable ELIXIR_ERL_OPTIONS="-epmd_module Elixir.Livebook.EPMD" before the command (and exclusively before the command)

tatotato

とりあえず指示通りに指定すれば動く。Livebook側で :erl_epmdをカスタマイズしている理由は:
TODO

tatotato
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

[notice]     :alarm_handler: {:set, {:system_memory_high_watermark, []}}
[info] Reading storage from  <>/tmp/livebook_data/dev/livebook_config.v1.ets
[info] Running LivebookWeb.IframeEndpoint with Bandit 1.6.8 at 127.0.0.1:4001 (http)
[Livebook] Application running at http://localhost:4000/
[info] Running LivebookWeb.Endpoint with Bandit 1.6.8 at 127.0.0.1:4000 (http)
Interactive Elixir (1.18.4) - press Ctrl+C to exit (type h() ENTER for help)
tatotato

tidewave のパッケージを入れようとしたら最初から入っていた。
そのため設定だけを済ます。

.mcp.json
{
  "mcpServers": {
    "tidewave": {
      "type": "http",
      "url": "http://localhost:4000/tidewave/mcp"
    }
  }
}
tatotato

Livebook 環境変数と意味、あるいはコード読解のきっかけとして。

tatotato

Livebook.config_runtime()なる関数がある。runtime.exsから呼び出している。

...どうやらLivebookそのものをアプリケーションにそのまま組み込んだときのために、関数でruntime.exsには書かずに呼び出す形を取っている模様。attachedとかもせずに入れ込むときのもの。だいぶニッチ?昔の名残のところもあるのだろうか。

tatotato

LIVEBOOK_ALLOW_URI_SCHEMES=ftp,others:

Livebookで https://github.com/rehypejs/rehype-sanitize を使っている。そのhref属性として使用可能なURIスキーマを加えることができる。

phx-hook="MarkdownRenderer"に渡されている。タグのdata-p-*属性を各Hookで使うオプション的なものとしている様子。

...手厚い。でも[hoge](others://example.com) の反映は確認できたけど、others://example.com直書きだとリンクにしてくれない。自動でリンク化するのはremark-gfmの仕事でそちらはカスタマイズできなさそうではある。

tatotato

LIVEBOOK_APP_SERVICE_NAME=:
LIVEBOOK_APP_SERVICE_URL=:

System settingに表示+リンク、詳しい用途不明。触ることはなさそう。

tatotato

LIVEBOOK_APPS_PATH=notes/apps/:

指定したディレクトリの.livemdをアプリケーションとして実行時にデプロイする(?)