logseq / graph-validator

Validate your logseq graphs
MIT License
48 stars 0 forks source link

Failure due to logseq/bak #3

Closed kerim closed 1 year ago

kerim commented 1 year ago

So I was finally able to run the logseq-graph-validator command from within the root folder of my graph, but I don't understand the results. What does this mean?

logseq-graph-validator
Downloading dependencies...
Extracting dependencies...
Done.
Parsing graph .

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^
el [Error]: ENOENT: no such file or directory, open './logseq/bak/logseq/config/2022-06-18T05_07_00.285Z.edn'
    at new el (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:179:94)
    at $APP.Sm.j (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:1267:319)
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:332:310
    at Jq (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:332:319)
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:562:45
    at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469)
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:421:113
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:561:498
    at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469)
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:563:263 {
  data: {
    K: null,
    O: 6,
    H: [
      {
        Nc: null,
        name: 'type',
        S: 'type',
        Vc: 1174270348,
        I: 2153775105,
        M: 4096
      },
      {
        Nc: 'sci',
        name: 'error',
        S: 'sci/error',
        Vc: -979082803,
        I: 2153775105,
        M: 4096
      },
      {
        Nc: null,
        name: 'line',
        S: 'line',
        Vc: 212345235,
        I: 2153775105,
        M: 4096
      },
      14,
      {
        Nc: null,
        name: 'column',
        S: 'column',
        Vc: 2078222095,
        I: 2153775105,
        M: 4096
      },
      3,
      {
        Nc: null,
        name: 'message',
        S: 'message',
        Vc: -406056002,
        I: 2153775105,
        M: 4096
      },
      "ENOENT: no such file or directory, open './logseq/bak/logseq/config/2022-06-18T05_07_00.285Z.edn'",
      {
        Nc: 'sci.impl',
        name: 'callstack',
        S: 'sci.impl/callstack',
        Vc: -1621010557,
        I: 2153775105,
        M: 4096
      },
      Hh {
        state: {
          K: null,
          first: {
            K: null,
            O: 5,
            H: [Array],
            D: null,
            I: 16647951,
            M: 139268
          },
          '$b': {
            K: null,
            first: [Object],
            '$b': [Object],
            count: 6,
            D: null,
            I: 65937646,
            M: 8192
          },
          count: 7,
          D: null,
          I: 65937646,
          M: 8192
        },
        I: 32768,
        M: 0
      },
      {
        Nc: null,
        name: 'file',
        S: 'file',
        Vc: -1269645878,
        I: 2153775105,
        M: 4096
      },
      '/Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/.nbb/.cache/b34aecd91133fb66d9a99efeb9e3073b9e151750/nbb-deps/logseq/graph_parser/cli.cljs'
    ],
    D: null,
    I: 16647951,
    M: 139268
  },
  cause: Error: ENOENT: no such file or directory, open './logseq/bak/logseq/config/2022-06-18T05_07_00.285Z.edn'
      at Object.openSync (node:fs:589:3)
      at Module.readFileSync (node:fs:457:35)
      at Zfa (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:337:230)
      at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:600:447
      at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469)
      at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:561:428
      at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469)
      at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:421:113
      at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:561:498
      at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469) {
    errno: -2,
    syscall: 'open',
    code: 'ENOENT',
    path: './logseq/bak/logseq/config/2022-06-18T05_07_00.285Z.edn'
  },
  description: undefined,
  number: undefined,
  fileName: undefined,
  lineNumber: undefined,
  columnNumber: undefined
}

Node.js v19.9.0
kerim commented 1 year ago

Looks like issues are mostly with my bak files, so I probably don't need to worry too much?

logseq-cldwalker commented 1 year ago

Looks like it's an unexpected failure due to logseq/bak. I'd recommend removing it from your git repo with git rm -rf logseq/bak. You can always go back in history if there's something you want from there. I'd also recommend not checking in future back up files by creating a .gitignore file with logseq/bak. If you don't want to do any of this permanently, you could just try this on a git branch so you can see this CLI running

kerim commented 1 year ago

OK. I ran that, this is what I get now. The only thing I can make out is an issue at the bottom that seems to have resulted from renaming a citation from Zotero: @friedmanExceptionalStatesChinese2015b.md is now @friedmanExceptionalStatesChinese2015.md but I tried to find and change all references with the extra "b" and even did s re-index, but that error is still showing...

 logseq-graph-validator
Parsing graph .

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^
el [Error]: ENOENT: no such file or directory, open './pages/@friedmanExceptionalStatesChinese2015b.md'
    at new el (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:179:94)
    at $APP.Sm.j (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:1267:319)
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:332:310
    at Jq (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:332:319)
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:562:45
    at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469)
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:421:113
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:561:498
    at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469)
    at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:563:263 {
  data: {
    K: null,
    O: 6,
    H: [
      {
        Nc: null,
        name: 'type',
        S: 'type',
        Vc: 1174270348,
        I: 2153775105,
        M: 4096
      },
      {
        Nc: 'sci',
        name: 'error',
        S: 'sci/error',
        Vc: -979082803,
        I: 2153775105,
        M: 4096
      },
      {
        Nc: null,
        name: 'line',
        S: 'line',
        Vc: 212345235,
        I: 2153775105,
        M: 4096
      },
      14,
      {
        Nc: null,
        name: 'column',
        S: 'column',
        Vc: 2078222095,
        I: 2153775105,
        M: 4096
      },
      3,
      {
        Nc: null,
        name: 'message',
        S: 'message',
        Vc: -406056002,
        I: 2153775105,
        M: 4096
      },
      "ENOENT: no such file or directory, open './pages/@friedmanExceptionalStatesChinese2015b.md'",
      {
        Nc: 'sci.impl',
        name: 'callstack',
        S: 'sci.impl/callstack',
        Vc: -1621010557,
        I: 2153775105,
        M: 4096
      },
      Hh {
        state: {
          K: null,
          first: {
            K: null,
            O: 5,
            H: [Array],
            D: null,
            I: 16647951,
            M: 139268
          },
          '$b': {
            K: null,
            first: [Object],
            '$b': [Object],
            count: 6,
            D: null,
            I: 65937646,
            M: 8192
          },
          count: 7,
          D: null,
          I: 65937646,
          M: 8192
        },
        I: 32768,
        M: 0
      },
      {
        Nc: null,
        name: 'file',
        S: 'file',
        Vc: -1269645878,
        I: 2153775105,
        M: 4096
      },
      '/Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/.nbb/.cache/b34aecd91133fb66d9a99efeb9e3073b9e151750/nbb-deps/logseq/graph_parser/cli.cljs'
    ],
    D: null,
    I: 16647951,
    M: 139268
  },
  cause: Error: ENOENT: no such file or directory, open './pages/@friedmanExceptionalStatesChinese2015b.md'
      at Object.openSync (node:fs:589:3)
      at Module.readFileSync (node:fs:457:35)
      at Zfa (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:337:230)
      at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:600:447
      at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469)
      at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:561:428
      at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469)
      at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:421:113
      at file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:561:498
      at Q (file:///Users/{home}/.config/yarn/global/node_modules/@logseq/graph-validator/node_modules/@logseq/nbb-logseq/lib/nbb_core.js:308:469) {
    errno: -2,
    syscall: 'open',
    code: 'ENOENT',
    path: './pages/@friedmanExceptionalStatesChinese2015b.md'
  },
  description: undefined,
  number: undefined,
  fileName: undefined,
  lineNumber: undefined,
  columnNumber: undefined
}

Node.js v19.9.0
kerim commented 1 year ago

I tried clearing the cache and re-indexing, but it didn't help.

kerim commented 1 year ago

I asked ChatGPT to explain the error message to me. I understand things a little better, but still don't know what to do. Here is what ChaptGPT said:

This error message is related to the Logseq Graph Validator, a tool used for validating graphs created using Logseq, a note-taking and knowledge management software. The error message indicates that the tool was attempting to parse a graph, but it encountered an error related to a missing file.

Specifically, the error message mentions that the file ./pages/@friedmanExceptionalStatesChinese2015b.md could not be found. The file path suggests that this file is a Markdown file located in the ./pages directory. The error message provides a stack trace with more detailed information about where the error occurred and the cause of the error.

The cause of the error is an ENOENT error, which is short for "Error NO ENTry." This error is thrown when a file or directory that does not exist is accessed or opened. The stack trace shows that the error occurred in the node:fs module when attempting to read the file.

It is possible that the file was deleted, moved, or renamed, or that the file path specified in the graph is incorrect. To resolve the error, you may need to locate the missing file or update the graph to reference the correct file path.

kerim commented 1 year ago

So I asked ChatGPT what I should do to fix the problem, and it suggested I create the page, so I did. Then I ran the validator again and it gave me another page, which I created ... and it gave me another page, and so on. I wonder if the validator couldn't just give me a list of all the pages at once?

But then I ran into a problem on the 5th page, because that was actually an alias for an existing page, so I couldn't create it. I stopped there.

kerim commented 1 year ago

I should also note that creating a page and then deleting it doesn't fix the problem - it will just show the error as existing again.

There are no backlinks (or unlinked pages) mentioning these problematic pages.

logseq-cldwalker commented 1 year ago

After renaming the page, have you checked in your changes to git? Currently the graph-validator assumes your git state is clean when running it e.g.:

$  git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
kerim commented 1 year ago

So it seems that "enable git auto commit" was turned off in the settings, even though I previously had it on. Turning it on and then restarting the validator eliminated all those problems, and gave me very different output. I don't understand the new output yet, but that is a different issue. Thanks.

PS: You may want to make clear in the readme that this setting needs to be turned on for this to work.

logseq-cldwalker commented 1 year ago

Glad the CLI runs. I've added a note in the readme about git status