org-roam / org-roam

Rudimentary Roam replica with Org-mode
https://www.orgroam.com
GNU General Public License v3.0
5.44k stars 476 forks source link

integer-or-marker-p, nil, skipping after system update #2381

Open 8513421 opened 1 year ago

8513421 commented 1 year ago

Hi. I'm using org roam on doom emacs. My system is manajro.

After the system update, the configuration of doom emacs fell apart as it often happens. I fixed it with sync but org-roam stopped working! After hours of trying to repair, searching the web, etc. Unfortunately I haven't found a solution...

For all notes that contain any https links or links to other notes - I get the error:

Error (org-roam): Failed to process /path/to/my_note1.org with error Wrong type argument: integer-or-marker-p, nil, skipping...

db sync, update org od locatoion - didnt work :(

Notes without links - works. I think it's something with the database but I don't know what...

Thanks in advance for your help!

publicimageltd commented 1 year ago

I have the same error. I have seen it caused by org-roam-link-replace-at-point and org-roam-db-insert-link when saving a note file. There seems to be a problem the way the links are processed. Here's a backtrace:

  org-roam-db-insert-link((link (:standard-properties [1976 2028 2019 2025 1 nil nil nil nil nil nil nil nil nil (paragraph (:standard-properties [1602 2676 1602 2675 1 1602 nil t nil nil nil nil element nil (section ...) nil nil #<buffer cassirerFormUndTechnik1985.org>])) nil nil #<buffer cassirerFormUndTechnik1985.org>] :type "id" :path "95706587-41c0-4f69-9a1d-8cf4135fb559" :format bracket :raw-link "id:95706587-41c0-4f69-9a1d-8cf4135fb559" :application nil :search-option nil)))
  org-roam-db-map-links((org-roam-db-insert-link))
  org-roam-db-update-file()
  org-roam-db-autosync--try-update-on-save-h()
  run-hooks(after-save-hook)
  basic-save-buffer(t)
  save-buffer(1)

I experience this error since I use the new Emacs 29.1.

publicimageltd commented 1 year ago

I just discovered that there is already an issue open, see #2361 !

publicimageltd commented 1 year ago

Following #2361, I upgraded straight.el (which I use) to the developer version and rebuilt all packages. That did the trick, it works now. The problem seems to be that straight.el on master branch does not recompile all dependencies when building org, and due to this incomplete recompilation, a certain (inlined) function call is directed to the internal org package.

The error is gone.

8513421 commented 1 year ago

Thanks! I didn't find this issue. I use doom emacs so I had to use a different procedure (described in that thread), which is:

  1. Added package! org :pin "ca873f7" to package.el (whatever it does ;P)
  2. Remove .locl from .emacs.d
  3. ~/.emacs.d/bin/doom sync
  4. ~/.emacs.d/bin/doom upgrade

I missed my second brain ;P

aragaer commented 3 months ago

Looks like the fix is to use new functions like org-element-begin instead of org-element-property :begin. However to keep backward compatibility with org 9.6 the code should check for that new function. The following code should work fine:

(defun org-roam-element-begin (element)
  (or (org-element-property :begin element)
      (org-element-begin element)))
markokocic commented 3 months ago

I have the same issue since upgrading org mode to 9.7 version.

kodtaku commented 3 months ago

so my changed roam files were failing and clearing the db and building it again was worse. @aragaer you're right on the money. I change org-roam-db.el function org-roam-db-insert-citation to use what you mentioned and volia it works. Thanks! working for now. :-)

slackline commented 3 months ago

I have the same issue since upgrading org mode to 9.7 version.

Exact same issue for me too. Each org-roam file I touch since upgrading no longer gets included when I org-roam-db-sync and so the database is slowly getting degraded.

I don't understand how to apply the solution offered by @aragaer ? I've looked at org-roam-db-.el and the org-roam-db-insert-citation function but it doesn't appear to useorg-element-property. I can see org-element-property is byte compiled and defined in org-element-ast.el. Recompiling org-roam as suggested by @publicimageltd didn't solve this either, still get the following on trying to org-roam-db-sync...

 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/bash.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/cycling.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/git.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/research_software_engineering.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/emacs_lisp.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/fittrackee.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/r.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/pennine_way.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/books.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/bash.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/cycling.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/git.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/research_software_engineering.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/emacs_lisp.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/fittrackee.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/r.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/pennine_way.org with error Wrong type argument: integer-or-marker-p, nil, skipping...
 ■  Error (org-roam): Failed to process /home/neil/org-roam/main/books.org with error Wrong type argument: integer-or-marker-p, nil, skipping...

Perhaps related on opening an org-roam file with a single src chunk of type elisp I get multiple....

 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
 ■  Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer  emacs_packages.org[emacs-lisp]> (emacs-lisp-mode)
aragaer commented 2 months ago

The fix is to go through all files and replace calls to org-element-property that access :begin, :end, :content-begin and :content-end. I've created a pull request with the fix applied.

slackline commented 2 months ago

Thanks for taking the time to help me @aragaer and for the PR that fixes this.

In the mean time, I'm naive/stupid and don't understand how to solve this.

I don't use :begin/ :end explicitly but have chunks such as

#+begin_src sh
set -euo pipefail
IFS=$'\n\t'
#+end_src

Which I am guessing call org-element-property when updating the database.

Should I be converting these to something else in light of changes in org-mode-9.7.* ?

aragaer commented 2 months ago

:begin and :end are used in multiple places in org-roam code -- my fix replaces them all with correct calls. As soon as you apply my fix, the issue should go away, no other changes are needed.

slackline commented 2 months ago

:facepalm: D'oh I see now that its not something I should be changing in my org-files rather its patching the org-roam code base. Apologies for not understanding it first time round and thank you for your patience.

kodtaku commented 2 months ago

Looks like lint likes to pacman spaces not tabs. ;-)

slackline commented 2 months ago

This appears to have been fixed in org-9.7.6-7a4527, just requires the database to be rebuilt and everything is back to normal and I can find all nodes.