doomemacs / doomemacs/core

Unable to run emacs batch mode

Open
#6,494 6 comments 2 reactions 0 assignees View on GitHub
core:cli is:bug
Dominant language
Emacs Lisp
Stars
22.7k
Forks
3.1k
Avg merge
10h 46m
Merged PRs (30d)
4

Description

### What did you expect to happen?

I am trying to run Emacs [in batch mode (in terminal) for exporting org-mode files to PDF](https://emacs.stackexchange.com/questions/10392/export-an-org-mode-file-as-a-pdf-via-command-line), using the following command:

```shell
emacs --debug-init -u "$(id -un)" --batch --eval '(load user-init-file)' notes.org -f org-latex-export-to-pdf
```

Note that the `--batch` option disables loading of any init files by default. Hence I am loading the init files using `eval` in the above command. If I simply use the `--batch` mode, the export runs fine, however it fails to load many org-mode packages and the exported pdf comes out to be incomplete (e.g. without syntax highlighting). Here is that bare-bones command:

```shell
emacs --batch notes.org -f org-latex-export-to-pdf
```

It does reproduce on Vanilla Doom (without my private config).

### What actually happened?

However, it throws the error:

```
Loading /etc/emacs/site-start.d/00debian.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Debugger entered--Lisp error: (void-function doom-initialize-packages)
(doom-initialize-packages)
(if noninteractive (doom-initialize-packages) (doom-initialize-core) (doom-initialize-modules))
eval-buffer(# nil "/home/dean/.emacs.d/init.el" nil t) ; Reading at buffer position 2724
load-with-code-conversion("/home/dean/.emacs.d/init.el" "/home/dean/.emacs.d/init.el" t t)
load("/home/dean/.emacs.d/init" noerror nomessage)
startup--load-user-init-file(#f(compiled-function () #) #f(compiled-function () #) t)
command-line()
normal-top-level()
```

### Describe your attempts to resolve the issue

I added the `--debug-init` option to trace the error but couldn't figure why it was not able to load the init file.

### Steps to reproduce

1. Have an org-mode file ready for export to pdf (through latex)
2. Open a terminal and run this command to export: `emacs -u "$(id -un)" --batch --eval '(load user-init-file)' notes.org -f org-latex-export-to-pdf`
3. It fails to export throwing the error: `Symbol’s function definition is void: doom-initialize-packages`
4. Note that the export runs if I don't load the Doom emacs init files: `emacs --batch notes.org -f org-latex-export-to-pdf`. The `--batch` command by default disables loading of any init files.

### System Information

https://pastebin.com/XTFC1RSj

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.