protesilaos / denote

Simple notes for Emacs with an efficient file-naming scheme
https://protesilaos.com/emacs/denote
GNU General Public License v3.0
517 stars 54 forks source link

File already exists after running 'denote-journal-extras-new-entry' #454

Open hyperfocus1337 opened 20 hours ago

hyperfocus1337 commented 20 hours ago

First of all, thanks for all the efforts in putting this package together! I could really relate to the reasoning behind the workings of package, and I wanted my notes in markdown thus I migrated away from org roam.

Unfortunately though, I am dealing with a critical error and I could use some guidance as to how I should go about troubleshooting it.

Whenever I execute denote-journal-extras-new-entry, I trigger the following error. It also happens intermittently when executing denote or denote-open-or-create. But I can successfully trigger the error every time I run denote-journal-extras-new-entry.

File notes/journal/20241008T154731--tuesday-8-october-2024-1547__journal.md added to project /Users/user/Library/CloudStorage/Dropbox/Notebooks/notebook/ cache.
Wrote /Users/user/Library/CloudStorage/Dropbox/Notebooks/notebook/notes/journal/20241008T154731--tuesday-8-october-2024-1547__journal.md
"notes/journal/20241008T154731--tuesday-8-october-2024-1547__journal.md" 1L, 17C written
denote--prepare-note: A file named ‘/Users/user/Library/CloudStorage/Dropbox/Notebooks/notebook/notes/journal/20241008T154731--tuesday-8-october-2024-1547__journal.md’ already exists

Afterwards, I'm left with the file that only includes the markdown heading (#) symbol, no frontmatter.

This is how I installed Denote using Doom Emacs.

In packages.el (I'm using the latest commit starting with855c06e):

(package! denote :recipe (:host github :repo "protesilaos/denote"))

In config.el:

(use-package! denote
  :custom
  (denote-directory (expand-file-name "~/Library/CloudStorage/Dropbox/Notebooks/notebook/notes"))
  (denote-known-keywords '("emacs" "doom" "config" "denote"))
  (denote-infer-keywords nil) ; Infer keywords from note's content
  (denote-file-type 'markdown-yaml) ; Set file type for notes ('markdown-yaml' or 'org')
  (denote-save-buffers t)
  :hook
  (dired-mode . denote-dired-mode))

Here's my full Emacs config.org, as well as my init.el, to check if something might be interfering from my personal configuration.

Is there anything else that I should provide to help debugging?

Also noticed you offer coaching, we could take that route too if it would be useful to check my config through a screen sharing session, and discuss other note taking workflow improvements in the process. Would be happy to collaborate on this.

protesilaos commented 4 hours ago

From: hyperfocus1337 @.***> Date: Tue, 8 Oct 2024 07:20:02 -0700

First of all, thanks for all the efforts in putting this package together!

You are welcome!

I could really relate to the reasoning behind the workings of package, and I wanted my notes in markdown thus I migrated away from org roam.

Unfortunately though, I am dealing with a critical error and I could use some guidance as to how I should go about troubleshooting it.

Whenever I execute denote-journal-extras-new-entry, I trigger the following error. It also happens intermittently when executing denote or denote-open-or-create. But I can successfully trigger the error every time I run denote-journal-extras-new-entry.

The intermittent error is concerning. I am not sure what it could be. We will need to dig deeper.

File notes/journal/20241008T154731--tuesday-8-october-2024-1547__journal.md added to project /Users/user/Library/CloudStorage/Dropbox/Notebooks/notebook/ cache.
Wrote /Users/user/Library/CloudStorage/Dropbox/Notebooks/notebook/notes/journal/20241008T154731--tuesday-8-october-2024-1547__journal.md
"notes/journal/20241008T154731--tuesday-8-october-2024-1547__journal.md" 1L, 17C written
denote--prepare-note: A file named ‘/Users/user/Library/CloudStorage/Dropbox/Notebooks/notebook/notes/journal/20241008T154731--tuesday-8-october-2024-1547__journal.md’ already exists

Do you know what is that first line about the cache? We do not handle that. Could it be that somehow the file path is generated outside of Denote and then when Denote gets to write to the file it finds that it is already there? Seems improbable, though I have no better guess right now.

Afterwards, I'm left with the file that includes empty frontmatter (just a # symbol).

This is how I installed Denote using Doom Emacs.

In packages.el (I'm using the latest commit starting with855c06e):

(package! denote :recipe (:host github :repo "protesilaos/denote"))

In config.el:

(use-package! denote
  :custom
  (denote-directory (expand-file-name "~/Library/CloudStorage/Dropbox/Notebooks/notebook/notes"))
  (denote-known-keywords '("emacs" "doom" "config" "denote"))
  (denote-infer-keywords nil) ; Infer keywords from note's content
  (denote-file-type 'markdown-yaml) ; Set file type for notes ('markdown-yaml' or 'org')
  (denote-save-buffers t)
  :hook
  (dired-mode . denote-dired-mode))

This configuration seems fine. Can you try to reproduce the error by running 'emacs -Q' on the command line? This will open an Emacs frame that has none of your and Doom's configurations. In that frame, put the following in the scratch buffer, change the path to where denote.el is on your system, evaluate the whole code, and then try to see if the error happens again. This will help us understand where the source of the problem is.

The code:

(require 'denote "path/to/denote.el")
(require 'denote-journal-extras "path/to/denote-journal-extras.el")

(setq denote-directory (expand-file-name "~/Library/CloudStorage/Dropbox/Notebooks/notebook/notes"))
(setq denote-known-keywords '("emacs" "doom" "config" "denote"))
(setq denote-infer-keywords nil) ; Infer keywords from note's content
(setq denote-file-type 'markdown-yaml) ; Set file type for notes ('markdown-yaml' or 'org')
(setq denote-save-buffers t)

(add-hook 'dired-mode-hook 'denote-dired-mode)

Here's my full Emacs config.org, as well as my init.el, to check if something might be interfering from my personal configuration.

Is there anything else that I should provide to help debugging?

Let's first check what we get from 'emacs -Q' before delving into the Doom bits. There might be a bug in Denote, which we will find this way. Otherwise, it will be something in Doom or your configuration.

Also noticed you offer coaching, we could take that route too if it's very time consuming to thoroughly check my config for any conflicting config or packages.

Sure, though this is independent of the maintenance work I do here: this is a community project and is available for free (and in freedom).

-- Protesilaos Stavrou https://protesilaos.com