Zero to Emacs and Org-roam: a step-by-step guide on Windows 10

This is the error (as expected, some syntax-related issue):
Error (use-package): Failed to parse package org-roam: use-package: :ensure wants exactly one argument

With one of your ideas I can say: Success!
The location (org-roam-db-location "c:/sqlite/org-roam.db") works now with the FULL path! NICE.

1 Like

Hmm.

I think I have run out of the ideas.
I don’t have suggestions – maybe, just maybe, you can add (add-to-list) like I do below… But I don’t believe this is the cause of your issue; it’s the only difference I can see.

This below just works; I installed Use-package to my vanilla Emacs, and tried the following.

(use-package org-roam
      :ensure t
      :hook
      (after-init . org-roam)
      :custom
      (add-to-list 'exec-path "~/bin/sqlite-tools-win32-x86-3320200"))

I put up my entire config file (init.el) that I use with vanilla Emacs (27.1 just upgraded from 26.3).

Video of my Emacs opening with this config.

It takes about 45 seconds; I am not touching anything, no keyboard inputs. Emacs gets launched in my Windows, updates the Org-roam DB, and then the side panel opens automatically.

There is an error in your use-package clause here.

the (add-hook 'after-init-hook 'org-roam-mode) clause needs to be under the :init section of use-package.

It’s functionally equivalent to what you had in your “old” version of your use-package configuration, so it seems like you just had a bad version of Org-roam installed.

1 Like

Hhm, I respectfully disagree:

(use-package org-roam
:ensure t
:hook
(after-init . org-roam)
:custom
(org-roam-directory “~/org/”)
(add-to-list 'exec-path “c:/sqlite/org-roam.db”)
:bind (:map org-roam-mode-map
((“C-c n l” . org-roam)

This is my new / old config and still calling org-roam-mode always is needed. :grimacing:
@nobiot: As you can see, I applied your add-to-list idea but no change. :woozy_face:

As :hook (after-init . org-roam) works on my PC, I think it’s unlikely that the cause of your issue is Org-roam, or Use-package, or this part of your config.

Questions would be:

  • Did you change anything else around 1 week ago when you started experiencing the issue?
  • Do you have any other config that uses :hook (after-init) or (add-hook 'after-init-hook)?

Something else seems to be interfering with your after-init-hook (both variations of the syntax are equivalently calling some functions in this hook). We seem to need to go outside of this section of your config to see what this “something” is.

Practically speaking, if I were you, I would see two options: (1) live with this issue (as it is minor); (2) go vanilla Emacs to identify the cause.

I would choose option (1) in this case (in fact, I always call Org-roam manually, since I don’t use it at the start of the day).

But if you have time, you could choose option (2). This would usually involve taking a backup of your config file, strip down your config to bare minimum, and then add your config back one section at a time… Time consuming. Some people call it “config bankrupt” and start all over from scratch (I don’t think your situation calls for it).

Just a minor point to add: the variable exec-path must be a list of
directories where you find relevant .exe files. So… it should not be set to your org-roam.db file, but should be like this: (add-to-list 'exec-path “path/to/sqlite3-dir”).

S U C C E S S
And you dear comrade brought me there:

  • Yes, I do have another (add-hook 'after-init-hook 'global-company-mode) in my one and only config.org
    (use-package company
    :ensure t
    :config
    (add-hook 'after-init-hook 'global-company-mode)
    (setq company-idle-delay 1)
    (setq company-minimum-prefix-length 3))
    …
  • That one is above the other
    #+begin_src emacs-lisp
    (use-package org-roam
    :ensure t
    :hook
    (after-init . org-roam)
    :custom
    (org-roam-directory “~/org/”)
    …
  • The first worked always, but org-roam wouldn’t even after commenting out company
  • BUT: I changed the latter to:
    (use-package org-roam
    :ensure t
    :init
    (add-hook 'after-init-hook 'org-roam-mode)
    :custom
    (org-roam-directory “~/org/”)
    …
  • And Boom, it worked

Learning:

  • Yes, multiple after-init-hooks are allowed, if done correctly
  • preferably preceded with :init

So here is my Messages buffer output now (even reopened Emacs after disbled org-roam-mode:
Loading c:/Users/JochenBurkhard/iCloudDrive/iCloud~com~appsonthemove~beorg/.emacs.d/config.el (source)…
[yas] Prepared just-in-time loading of snippets successfully.
Loading c:/Users/JochenBurkhard/iCloudDrive/iCloud~com~appsonthemove~beorg/.emacs.d/config.el (source)…done
Loaded c:/Users/JochenBurkhard/iCloudDrive/iCloud~com~appsonthemove~beorg/.emacs.d/config.el
(org-roam) files: Δ0, headlines: Δ0, links: Δ0, tags: Δ0, titles: Δ0, refs: Δ0, deleted: Δ0
Loading c:/Users/JochenBurkhard/iCloudDrive/iCloud~com~appsonthemove~beorg/.emacs.d/recentf…done
Cleaning up the recentf list…done (0 removed)
For information about GNU Emacs and the GNU system, type C-h C-a.
Package cl is deprecated

1 Like

Many thanks for your guide @nobiot and mainly for the step by step guide to set up org-protocol. It was the missing part of my workflow on my windows platform. It works like a charm right now.

1 Like

Thank you, @altomcat

Just as a side note, there seems to be an alternative way to do this with Firefox that does not require editing the registry (reported via org-roam GitHub repo).

I haven’t tried it myself, but it’s good to know. Pasting the comment below.


Just fyi: I managed to get links working without the need of changing the windows registry. When using Firefox, you can add a custom protocol handler in about:config :

  • Type about:config into your address bar, confirm the dialog
  • enter network.protocol-handler.expose.org-protocol in the search bar
  • Leave the option boolean , hit + and change the value to false
  • Next time you try to open an org-protocol link, Firefox will ask you what program to use
  • Choose emacsclientw and make this permanent (check ‘remember my choice’/‘alway open with’)

Perhaps in time for Christmas, I have changed the gear a bit, and added some decoration to vanilla Emacs.

Enjoy the festive season, and have fun roaming :slight_smile:

  1. Make vanilla Emacs look like Doom

1 Like

A Happy New Year to all.

Just uploaded a new chapter. It talks about a solution on Windows for inserting an image file from the clipboard (or from using Snipping Tool).

Insert an image from the clipboard, or the Snipping Tool on Windows

[Edit 2021-01-17: Now it looks like org-download works on my Windows! Yay. I will play with it and update the Zero guide when I know more about it] I have never been able to get org-download to work on Windows. Perhaps this is a detour, if someone knows how to do it; nevertheless, this solution works quite well on my set up and for my workflow.

Edit: I added a part where I talk about in-line display resizing without Imagemagick; it’s just a matter of setting a variable.

1 Like

@nobiot a huge huge thanks! Your Ch. 9 was immensely helpful in getting Graph View working for me. Without the help of your chapter, I tried several months ago and gave up after getting past installing graphviz. I’m on a Mac and was initially not optimistic that your chapter (with Windows in the title) could help. But, I was pleasantly surprised. You provide a good description of how the different parts fit together, what role each (org-protocol, org-roam-protocol, org-roam-server, and so on) plays. This was helpful in translating the key concepts to get it working on the Mac. I am looking forward to looking over the other chapters of your manual! Kudos to you for assembling and sharing a fantastic resource.

1 Like

First of all, great work :slight_smile:
I have the problem (WS10, nondev, new to emacs) that the icon installation in the customizing chapter didn’t work, so now I just get these boxes.
I followed the instruction until that point , and i have everything for that chapter setup like in the description, except use another theme; switching to the doom theme also doesn’t change that I didn’t find all-the-icons via package manager at first, but installed it via inserting. i can call the functions for icon management related to the pkg, but the icons will never be shown, just squares with zeros. help would be welcome :slight_smile:

How about the steps described here?

worked :slight_smile:
i just used the directory that i already set up - i had already installed the fonts. the connection was not so obvious at first.

1 Like

what was the problem?

This was not on you but

Provide a temp directory where you’d like the fonts to be downloaded (let’s call it $tempFonts )

I was wondering whether I should have put the fonts in a different place… a temp directory^^ was just mentioning it for the case that you would put it into the tutorial (:

1 Like

First of all, thank you very much for all this! I’ve been a long-time user of Emacs in Linux but had to switch to Windows recently. I also have a huge .bib file continuously updated by Mendeley. I followed your guide to the very end, save for the roam-server stuff, since I’ve never used graphs for note-taking: my goal is to have a handy way of annotating my PDFs in Emacs, and keeping track of it [perhaps I will move to graphs later on].

However, I have zero success with opening the PDFs whose locations are stored in the .bib file. For testing I created a .bib with a single paper stored at ~/pdfs/Brier1.pdf (and so the entry contains the line “file = {:~/pdfs/Brier1.pdf:pdf}”). I can run “C-x C-f ~/pdfs/Brier1.pdf” and the PDF opens in Emacs. When I press F6, the paper appears on the list with the ‘PDF available’ icon. I press ENTER and the citation is created. When I click on it, many options appear; among them ‘2. Open pdf’ and ‘User functions: Open pdf in emacs’. The first one leads to ‘no pdf found for brier1950’ (‘brier1950’ is the citekey). The second one leads to ‘concat: Wrong type argument: stringp, nil’. Both of them display the paper info: ‘Brier, G. W., Verification of forecasts expressed in terms of probability, Monthly Weather Review, 78(1), 25–27 (1950). http://dx.doi.org/10.1126/science.27.693.594’. However, when I press ‘3. Add notes’, a new buffer opens, with ‘:NOTER_DOCUMENT: ~/pdfs/Brier1.pdf’, seemingly as it should! Would you have any guesses as to what I could be doing wrong?

Thank you again for putting this guide together!

On vacation with no laptop, can’t verify what i’ll be saying.

two suggestions.
for mendeley, see GitHub - tmalsburg/helm-bibtex: Search and manage bibliographies in Emacs.
you might need this: (setq bibtex-completion-pdf-field “File”)
or you might need to make this variable nil to use a standard path resolution logic. experiment with the variable. the documentation suggests that paths created by mendeley would work.

if this does not work, there is an extensive discussion and a solution here

also… i don’t know which package you are using to open pdf documents when you do all the f6 click navigation. if it ends up calling an org-ref function, you might want to refer to this

Mendeley users should set to:
(setq org-ref-get-pdf-filename-function 'org-ref-get-mendeley-filename)

Thank you very much. Will explore these options!