Neorg dirman: Auto‑creation of missing workspace directories during setup
0 reputation · 26 Feb 2023, 21:17 UTC
0 reputation · 26 Feb 2023, 21:17 UTC
The goal is to recover safely from a failed Neorg upgrade that leaves workspace mappings pointing to non‑existent directories. When neorg.setup loads, it maps workspace names to filesystem paths, but the corresponding directories and index.norg files are not created automatically.
After an upgrade, the dirman.workspaces table may still reference old paths that no longer exist, and attempting :Neorg dirman index <workspace> triggers an error because the directory or index.norg is missing. Neorg does not create these directories during neorg.setup and the :Neorg dirman create-workspace command must be invoked manually. It is unclear whether a configuration option can enable automatic creation of missing workspaces, and which recovery steps are recommended for a user who has just upgraded and found their workspace structure broken.
neorg.setup, or is manual creation required?index.norg files during setup?index.norg files during neorg.setup(). The dirman module validates that configured paths exist but performs no filesystem creation.dirman (as of Neorg v8/v9) that enables automatic creation of missing workspace directories or index files during setup.:Neorg dirman workspaces to list configured workspaces and confirm which ones show as missing.dirman.workspaces table in your Neorg config to point to the new paths before creating anything.:Neorg dirman create-workspace <name> (where <name> matches the key in dirman.workspaces exactly, case‑sensitive). This creates the directory and an empty index.norg file.:Neorg dirman index <workspace> to rebuild the workspace index.The dirman module treats workspace paths as user‑managed locations. During setup() it only registers the mappings; it never calls vim.fn.mkdir() or writes index.norg. If an upgrade (or a config change) leaves a mapping pointing to a path that doesn’t exist, dirman emits an error but continues loading. Subsequent commands like :Neorg dirman index fail because the directory and/or index file are absent.
:Neorg dirman workspaces – shows each workspace, its path, and whether the directory exists.:Neorg dirman index <missing-workspace> – confirms the “directory or index.norg missing” error.:Neorg dirman create-workspace <missing-workspace> – creates the directory and index.norg at the configured path.:Neorg dirman index <workspace> again to verify.create-workspace on an already‑valid workspace will error; verify the path is truly missing first.index.norg file still causes index to fail; the file must exist (can be empty initially).dirman.workspaces exactly.Did the upgrade also change the root directory where workspaces are expected to live (e.g., ~/neorg → ~/.local/share/neorg)? If yes, update dirman.workspaces in your config before running create-workspace; otherwise the command will recreate the old (wrong) paths.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.