kaushalmodi / ox-hugo

A carefully crafted Org exporter back-end for Hugo
https://ox-hugo.scripter.co
GNU General Public License v3.0
867 stars 130 forks source link

void-function update-directory-autoload #667

Closed vinurs closed 1 year ago

vinurs commented 1 year ago

i use the latest Emacs in https://github.com/emacs-mirror/emacs

Actual Behavior

make md

Expected Behavior

export the org files to md files

How to Reproduce the Issue

git clone https://github.com/kaushalmodi/ox-hugo.git
cd ox-hugo
make md

Example Org File

Generated Markdown File or Error

Loading /Users/vinurs/tmp/ox-hugo/test/setup-ox-hugo.el (source)...
Debug on Error enabled globally
Debugger entered--Lisp error: (void-function update-directory-autoloads)
  (update-directory-autoloads ox-hugo-site-git-root)
  (let ((generated-autoload-file ox-hugo-autoloads-file)) (update-directory-autoloads ox-hugo-site-git-root) (load-file ox-hugo-autoloads-file))
  (progn (setq load-prefer-newer t) (setq package-user-dir (format "%selpa_%s/" ox-hugo-tmp-dir emacs-major-version)) (require 'package) (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) (not (gnutls-available-p)))) (protocol (if no-ssl "http" "https")) (melpa-url (concat protocol "://melpa.org/packages/"))) (let* ((x (cons "melpa" melpa-url))) (if (member x package-archives) package-archives (setq package-archives (append package-archives (list x)))))) (setq package-archives (delq (assoc "nongnu" package-archives) package-archives)) (let ((generated-autoload-file ox-hugo-autoloads-file)) (update-directory-autoloads ox-hugo-site-git-root) (load-file ox-hugo-autoloads-file)) (package-initialize) (add-to-list 'load-path (concat ox-hugo-site-git-root "doc/")) (add-to-list 'load-path ox-hugo-site-git-root) (defvar ox-hugo-missing-packages 'nil "List populated at each startup that contains the l...") (let ((--dolist-tail-- ox-hugo-packages) p) (while --dolist-tail-- (setq p (car --dolist-tail--)) (if (package-installed-p p) nil (if (member p ox-hugo-missing-packages) ox-hugo-missing-packages (setq ox-hugo-missing-packages (append ox-hugo-missing-packages (list p))))) (setq --dolist-tail-- (cdr --dolist-tail--)))) (if ox-hugo-missing-packages (progn (message "Emacs is now refreshing its package database...") (package-refresh-contents) (let ((--dolist-tail-- ox-hugo-missing-packages) p) (while --dolist-tail-- (setq p (car --dolist-tail--)) (message "Installing `%s' .." p) (package-install p) (setq --dolist-tail-- (cdr --dolist-tail--)))) (setq ox-hugo-missing-packages 'nil))))
  (if (and (stringp ox-hugo-tmp-dir) (file-exists-p ox-hugo-tmp-dir)) (progn (setq load-prefer-newer t) (setq package-user-dir (format "%selpa_%s/" ox-hugo-tmp-dir emacs-major-version)) (require 'package) (let* ((no-ssl (and (memq system-type '...) (not (gnutls-available-p)))) (protocol (if no-ssl "http" "https")) (melpa-url (concat protocol "://melpa.org/packages/"))) (let* ((x (cons "melpa" melpa-url))) (if (member x package-archives) package-archives (setq package-archives (append package-archives (list x)))))) (setq package-archives (delq (assoc "nongnu" package-archives) package-archives)) (let ((generated-autoload-file ox-hugo-autoloads-file)) (update-directory-autoloads ox-hugo-site-git-root) (load-file ox-hugo-autoloads-file)) (package-initialize) (add-to-list 'load-path (concat ox-hugo-site-git-root "doc/")) (add-to-list 'load-path ox-hugo-site-git-root) (defvar ox-hugo-missing-packages 'nil "List populated at each startup that contains the l...") (let ((--dolist-tail-- ox-hugo-packages) p) (while --dolist-tail-- (setq p (car --dolist-tail--)) (if (package-installed-p p) nil (if (member p ox-hugo-missing-packages) ox-hugo-missing-packages (setq ox-hugo-missing-packages (append ox-hugo-missing-packages ...)))) (setq --dolist-tail-- (cdr --dolist-tail--)))) (if ox-hugo-missing-packages (progn (message "Emacs is now refreshing its package database...") (package-refresh-contents) (let ((--dolist-tail-- ox-hugo-missing-packages) p) (while --dolist-tail-- (setq p (car --dolist-tail--)) (message "Installing `%s' .." p) (package-install p) (setq --dolist-tail-- (cdr --dolist-tail--)))) (setq ox-hugo-missing-packages 'nil)))) (error "The environment variable OX_HUGO_TMP_DIR needs to ..."))
  load-with-code-conversion("/Users/vinurs/tmp/ox-hugo/test/setup-ox-hugo.el" "/Users/vinurs/tmp/ox-hugo/test/setup-ox-hugo.el" nil nil)
  load-file("/Users/vinurs/tmp/ox-hugo/test/setup-ox-hugo.el")
  (progn (setenv "OX_HUGO_TMP_DIR" "/tmp/vinurs/ox-hugo-dev") (load-file (expand-file-name "setup-ox-hugo.el" "/Users/vinurs/tmp/ox-hugo/test")) (print-emacs-org-versions))
  command-line-1(("--eval" "(progn(setenv \"OX_HUGO_TMP_DIR\" \"/tmp/vinurs/ox-hu..." "--kill"))
  command-line()
  normal-top-level()

make: *** [vcheck_emacs] Error 255
kaushalmodi commented 1 year ago

The update-directory-autoloads is a core Emacs function that's been there for many years. It's present is the latest commit to master (as of today 2022/08/14) as well: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp/autoload.el?id=6f36b67e4146ef4610916b7903fd292e1308daf5#n1027. It's part of the Emacs core library autoload.el.

make md gets called during ox-hugo auto testing on GitHub Actions as well. I haven't noticed this error yet.

Can you review your Emacs installation? What changed between the last time this worked and now?

vinurs commented 1 year ago

it seems there is no lisp/emacs-lisp/autoload.el file in the master https://github.com/emacs-mirror/emacs

kaushalmodi commented 1 year ago

I am not aware of that mirror. Can you clone from the official repo https://git.savannah.gnu.org/cgit/emacs.git/ ?

kaushalmodi commented 1 year ago

Actually, you are right! It looks like that autoload.el has been moved/changed on that master branch: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp

Let me know if you find an alternative for update-directory-autoloads on the master branch. You can ask about this on the Emacs devel mailing list or review the commit history and NEWS file.

kaushalmodi commented 1 year ago

https://git.savannah.gnu.org/cgit/emacs.git/tree/etc/NEWS?id=d6831d1b0a18882d688a842721dd1592884a06e2#n487

The autoload.el is now obsolete. I'll add some workaround for this. Thanks for opening this issue.

kaushalmodi commented 1 year ago

@vinurs Hello, does this patch fix this issue for you?

diff --git a/test/setup-ox-hugo.el b/test/setup-ox-hugo.el
index e19fb93..4d8b030 100644
--- a/test/setup-ox-hugo.el
+++ b/test/setup-ox-hugo.el
@@ -155,9 +155,11 @@ Emacs installation.  If Emacs is installed using
       (setq package-archives (delq (assoc "nongnu" package-archives) package-archives))

       ;; Generate/update and load the autoloads for ox-hugo.el and co.
-      (let ((generated-autoload-file ox-hugo-autoloads-file))
-        (update-directory-autoloads ox-hugo-site-git-root)
-        (load-file ox-hugo-autoloads-file))
+      (if (fboundp #'loaddefs-generate) ;Emacs 29+
+          (loaddefs-generate ox-hugo-site-git-root ox-hugo-autoloads-file)
+        (let ((generated-autoload-file ox-hugo-autoloads-file)) ;Emacs 28.x and older
+          (update-directory-autoloads ox-hugo-site-git-root)))
+      (load-file ox-hugo-autoloads-file)

       ;; Load emacs packages and activate them.
       ;; Don't delete this line.

I don't have Emacs 29 built, so I cannot test it.

kaushalmodi commented 1 year ago

@vinurs I have closed this issue as the change in https://github.com/kaushalmodi/ox-hugo/pull/676 passed the CI run on emacs 29 as well. Let me know if this fix doesn't work for you and I'll reopen this issue.

vinurs commented 1 year ago

@kaushalmodi sorry for late reply, i tested it just now, it has beed fixed, thanks for ur help ^_^

kaushalmodi commented 1 year ago

Thanks for confirming.