Install org-roam manually

What if I install org-roam manually, should I require all those .el files ?

like this

(require 'org-roam)
(require 'org-roam-db)
(require 'org-roam-capture)
(require 'org-roam-compat)
...
;; extensions
(require 'org-roam-dailies)
(require 'org-roam-export)
(require 'org-roam-graph)
(require 'org-roam-overlay)

Because there’s no variable org-roam--sqlite-available-p in my Emacs

Interesting question. To be honest I manually install all my packages because I whole heartedly do not like wholesale upgrade … I don’t like to upgrade ever. But I skipped over installing org-roam the manual way because it has too many dependencies.

Are all the dependencies satisfied? I think that video is extremely dated probably. There doesn’t exist a variable as such that is known to me, or I can find using grep.

I think you are right, the video is dated.

Don’t remove files.

Leave in them in their own directory and modify the load-path and add their directory.

This way if there are any updates, you can simply replace the entire directory.

1 Like

I’m not removing any file.

As a side note - I created a function that will download packages from melpa and then recursively download their dependencies, I found that org-roam doesn’t have many external dependencies - or dependencies of dependencies.

So for anyone trying to install manually,

dash emacsql magit-section llama

these are the only dependencies necessary.

Here is my function (Hidden as spoiler)
remember to refresh contents :slight_smile:

Summary
(require 'package)
(require 'url)
(require 'tar-mode)
(require 'bytecomp)

(defun packages-download (pkg-name dest-dir &optional byte-compile-p force-deps)
  "Download PKG-NAME from MELPA, extract it into DEST-DIR, and optionally BYTE-COMPILE it.
Recursively downloads and extracts dependencies too.

When optional FORCE-DEPS is non-nil do not check if dep is already available."
  (interactive
   (list (intern (completing-read "Package: " (mapcar #'car package-archive-contents)))
         (read-directory-name "Destination directory: ")
         (y-or-n-p "Byte-compile extracted .el files? ")))

  ;; Refresh if necessary
  (unless package-archive-contents
    (package-refresh-contents))

  (let* ((pkg-sym (if (symbolp pkg-name) pkg-name (intern pkg-name)))
         (pkg-desc (cadr (assoc pkg-sym package-archive-contents))))
    (unless pkg-desc
      (error "Package %s not found in archive contents" pkg-sym))

    (let* ((version-str (package-version-join (package-desc-version pkg-desc)))
           (tar-name (format "%s-%s.tar" pkg-sym version-str))
           (tar-url (format "https://melpa.org/packages/%s" tar-name))
           (download-path (expand-file-name tar-name dest-dir))
           (extract-path (expand-file-name (symbol-name pkg-sym) dest-dir)))

      (message "Downloading %s ..." tar-url)
      (url-copy-file tar-url download-path t)
      (message "Downloaded to %s" download-path)

      ;; Extract
      (make-directory extract-path t)
      (let ((default-directory extract-path))
	(with-temp-buffer
	  (insert-file-contents-literally download-path)
	  (tar-mode)
	  (tar-untar-buffer))

	(message "Extracted %s to %s" tar-name extract-path)

	;; Move nested contents up one level
	(let* ((entries (directory-files default-directory t "^[^.]"))
	       (subdir (car (seq-filter #'file-directory-p entries))))
	  (when (and subdir (not (equal subdir default-directory)))
	    (dolist (item (directory-files subdir t "^[^.]+"))
	      (let ((target (expand-file-name (file-name-nondirectory item) default-directory)))
		(if (file-directory-p item)
		    (copy-directory item target t t t) 
		  (copy-file item target t)))) 
	    (delete-directory subdir t)))
	;; Byte-compile if requested
	(when byte-compile-p
	  (add-to-list 'load-path default-directory)
	  (byte-recompile-directory default-directory 0)))

      ;; Recursively handle dependencies
      (dolist (dep (package-desc-reqs pkg-desc))
        (let ((dep-name (car dep)))
          (unless 
	    (cond
	     ((package-built-in-p dep-name) t)
	     ((string= dep-name "compat") t)
	     ((not force-deps)
	      (or (featurep dep-name)
		  (locate-library (symbol-name dep-name))))
	     (t nil))
            (message "Installing dependency: %s" dep-name)
            (packages-download dep-name dest-dir byte-compile-p force-deps)))))))