elpaca icon indicating copy to clipboard operation
elpaca copied to clipboard

[Bug/Support]: Error reading `melpa.eld` into memory: (invalid-read-syntax "# " 1 797933)

Open ISouthRain opened this issue 1 month ago • 12 comments

Confirmation

  • [x] I have checked the documentation (README, Wiki, docstrings, etc)
  • [x] I am checking these without reading them.
  • [x] I have searched previous issues to see if my question is a duplicate.

Elpaca Version

Elpaca 8050db1 HEAD -> master, origin/master, origin/HEAD installer: 0.11 emacs-version: GNU Emacs 31.0.50 (build 1, x86_64-w64-mingw32) of 2025-09-05 git --version: git version 2.39.2.windows.1

Operating System

Windows 10

Description

Hey~~~ I found a new problem.

This is a very random problem, and it can happen in two ways:

  1. elpaca-try New package
  2. Use init.el config
;; I use elpaca-use-package
(use-package new-package
  :ensure t)

Emacs warning:

⛔ Warning (emacs): Error reading "c:/Users/adminuirs/AppData/Roaming/.emacs.d/elpaca/cache/melpa.eld" into memory: (invalid-read-syntax "# " 1 797933)

The summary is that this problem may occur when you install a New package, and the Warning will still appear after restarting Emacs.

Fixed issue: When using elpaca-delete to new package it returns to normal.

NOTE: This is a random issue, some new packages may not cause problems.

Finally, how should I debug the problem?

The following configuration is the configuration that caused the problem on my computer:

(use-package tabnine
  :ensure t
  :hook
  ((c-mode c-ts-mode c++-mode c++-ts-mode rust-mode rust-ts-mode) . tabnine-mode)
  :init
  (setq tabnine-binaries-folder "~/.emacs.d.cache/.TabNine")
  (setq tabnine-executable-args (list "--log-level" "Error" "--no-lsp" "false"))
  )

ISouthRain avatar Oct 13 '25 08:10 ISouthRain

Thanks for taking the time to fill out a bug report.

The error you're seeing points to a syntax error in the cached recipes for MELPA:

(invalid-read-syntax "# " 1 797933)

It's hard for me to diagnose without seeing that file, though. If you are able to reproduce the issue please upload:

"c:/Users/adminuirs/AppData/Roaming/.emacs.d/elpaca/cache/melpa.eld"

Fixed issue: When using elpaca-delete to new package it returns to normal.

Elpaca delete doesn't modify the MELPA recipe cache, so it's odd that it would solve the issue. Perhaps there's something else at play. You could try instead to remove the melpa.eld file and see if that fixes the issue.

progfolio avatar Oct 15 '25 01:10 progfolio

OK, I conducted the following tests: When the error occurred, I deleted the melpa.eld file, then I restarted Emacs and the problem was resolved. Then I restarted Emacs again and the problem continued.

Then, I compared the normal and error melpa.eld files, and there was no difference between them.

It is speculated that it may be an error in the melpa.eld file, because Emacs starts normally after deleting it, but then elpaca generates a melpa.eld file, causing an error.

Please note that anyway, as long as I don't use new package the tabnine, elpaca works fine without errors.

appendix: melpa.zip

ISouthRain avatar Oct 15 '25 02:10 ISouthRain

Interesting. Does the error occur in the following test environment?:

How to run this test?

(elpaca-test
  :interactive t
  :init
  (setq first-run
        (not (file-exists-p (expand-file-name "tabnine" elpaca-repos-directory))))
  (elpaca (tabnine :wait t))
  (when first-run (restart-emacs)))

progfolio avatar Oct 16 '25 00:10 progfolio

M-x eval-buffer

(elpaca-test
  :interactive t
  :init
  (setq first-run
        (not (file-exists-p (expand-file-name "tabnine" elpaca-repos-directory))))
  (elpaca (tabnine :wait t))
  (when first-run (restart-emacs)))

On main Emacs log:

Testing Elpaca in c:/Users/Jack/AppData/Local/Temp/elpaca.W2TTA9 @ master
Removing Elpaca test env: "c:/Users/Jack/AppData/Local/Temp/elpaca.W2TTA9"
error in process sentinel: apply: Removing directory: Directory not empty, c:/Users/Jack/AppData/Local/Temp/elpaca.W2TTA9/elpaca
error in process sentinel: Removing directory: Directory not empty, c:/Users/Jack/AppData/Local/Temp/elpaca.W2TTA9/elpaca

On New Test Emacs log:

Debugger entered--Lisp error: (file-missing "c:\\Users\\Jack\\AppData\\Local\\Temp\\elpaca.W2TTA9\\elpaca\\repos\\elpaca\\elpaca-log.el")
  comp-el-to-eln-filename("c:/Users/Jack/AppData/Local/Temp/elpaca.W2TTA9/elpaca/repos/elpaca/elpaca-log.el")
  #f(compiled-function (process event) #<bytecode 0x1b934a79970efb92>)(#<process Compiling: c:/Users/Jack/AppData/Local/Temp/elpaca.W2TTA9/elpaca/repos/elpaca/elpaca-log.el> "exited abnormally with code 255\n")

ISouthRain avatar Oct 16 '25 11:10 ISouthRain

Thanks. It looks like the install didn't go smoothly in that test environment for some reason. Can you try running this one instead?:

elpaca-test
  :interactive t
  :keep t
  :init
  (setq first-run
        (not (file-exists-p (expand-file-name "tabnine" elpaca-repos-directory))))
  (elpaca (tabnine :wait t))
  (when first-run (restart-emacs)))

progfolio avatar Oct 18 '25 15:10 progfolio

This time elpaca-test went very smoothly, Emacs started normally without any errors. I used elpacal-log to check, and it was completely normal.

elpaca                         finished             ✓ 0.149 secs                                                                     00.205795
language-id                    finished             ✓ 0.000 secs                                                                     00.207525
s                              finished             ✓ 0.001 secs                                                                     00.208143
tabnine                        finished             ✓ 0.032 secs                                                                     00.209395
dash                           finished             ✓ 0.002 secs                                                                     00.209397

ISouthRain avatar Oct 19 '25 12:10 ISouthRain

Interesting. I've not been able to reproduce the issue on my end in a Windows environment. It might be useful to start adding bits of your init.el to that test case to see if any settings are causing the issue.

progfolio avatar Oct 22 '25 23:10 progfolio

(if (and (and (eq system-type 'gnu/linux)) (string-match-p "Microsoft" (shell-command-to-string "uname -r")) (>= emacs-major-version 31) t)
    (setq elpaca-core-date '("20250904")))

(defvar elpaca-installer-version 0.11)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
                              :ref nil :depth 1 :inherit ignore
                              :files (:defaults "elpaca-test.el" (:exclude "extensions"))
                              :build (:not elpaca--activate-package)))
(let* ((repo  (expand-file-name "elpaca/" elpaca-repos-directory))
       (build (expand-file-name "elpaca/" elpaca-builds-directory))
       (order (cdr elpaca-order))
       (default-directory repo))
  (add-to-list 'load-path (if (file-exists-p build) build repo))
  (unless (file-exists-p repo)
    (make-directory repo t)
    (when (<= emacs-major-version 28) (require 'subr-x))
    (condition-case-unless-debug err
        (if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
                  ((zerop (apply #'call-process `("git" nil ,buffer t "clone"
                                                  ,@(when-let* ((depth (plist-get order :depth)))
                                                      (list (format "--depth=%d" depth) "--no-single-branch"))
                                                  ,(plist-get order :repo) ,repo))))
                  ((zerop (call-process "git" nil buffer t "checkout"
                                        (or (plist-get order :ref) "--"))))
                  (emacs (concat invocation-directory invocation-name))
                  ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
                                        "--eval" "(byte-recompile-directory \".\" 0 'force)")))
                  ((require 'elpaca))
                  ((elpaca-generate-autoloads "elpaca" repo)))
            (progn (message "%s" (buffer-string)) (kill-buffer buffer))
          (error "%s" (with-current-buffer buffer (buffer-string))))
      ((error) (warn "%s" err) (delete-directory repo 'recursive))))
  (unless (require 'elpaca-autoloads nil t)
    (require 'elpaca)
    (elpaca-generate-autoloads "elpaca" repo)
    (let ((load-source-file-function nil)) (load "./elpaca-autoloads"))))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))

;; Windows require
(if (and (eq system-type 'windows-nt))
    (elpaca-no-symlink-mode))

;; My lock file, but No use `tabnine` on file to lock.
(setq elpaca-lock-file "~/.emacs.d/elpaca-lock-file.el")

;; use-package Integration
(elpaca elpaca-use-package
  ;; Enable Elpaca support for use-package's :ensure keyword.
  (elpaca-use-package-mode))
;; My package config
(use-package A)
(use-package B)

init.el End:

(setq elpaca-after-init-time (or elpaca-after-init-time (current-time)))
(elpaca-wait)

ISouthRain avatar Oct 23 '25 00:10 ISouthRain

Interesting. I've not been able to reproduce the issue on my end in a Windows environment.

You should try to install many different packages because it is a random problem that can happen with any package.

This is my config elpaca all package:

 Package Status Info Time ▼ 
elpaca                         finished             ✓ 0.145 secs                                                                     00.153084
elpaca-use-package             finished             ✓ 0.144 secs                                                                     00.153792
diminish                       finished             ✓ 5.800 secs                                                                     05.988477
theme-changer                  finished             ✓ 4.529 secs                                                                     05.989624
s                              finished             ✓ 0.001 secs                                                                     05.992872
elisp-refs                     finished             ✓ 0.003 secs                                                                     05.994902
dash                           finished             ✓ 0.003 secs                                                                     05.994908
helpful                        finished             ✓ 4.536 secs                                                                     05.996483
f                              finished             ✓ 0.005 secs                                                                     05.996484
vertico                        finished             ✓ 4.537 secs                                                                     05.997826
orderless                      finished             ✓ 4.538 secs                                                                     05.998944
pinyinlib                      finished             ✓ 4.540 secs                                                                     06.000887
consult                        finished             ✓ 4.541 secs                                                                     06.002705
consult-todo                   finished             ✓ 4.543 secs                                                                     06.005003
hl-todo                        finished             ✓ 3.789 secs                                                                     06.005005
marginalia                     finished             ✓ 4.544 secs                                                                     06.006336
embark                         finished             ✓ 4.546 secs                                                                     06.007962
embark-consult                 finished             ✓ 4.546 secs                                                                     06.009038
org-protocol-capture-html      finished             ✓ 4.188 secs                                                                     06.010068
ox-hugo                        finished             ✓ 4.190 secs                                                                     06.012682
tomelr                         finished             ✓ 0.000 secs                                                                     06.012684
llama                          finished             ✓ 0.001 secs                                                                     06.041605
magit-section                  finished             ✓ 0.029 secs                                                                     06.043361
cond-let                       finished             ✓ 0.002 secs                                                                     06.043362
org-roam                       finished             ✓ 4.222 secs                                                                     06.045225
emacsql                        finished             ✓ 0.030 secs                                                                     06.045227
org-cliplink                   finished             ✓ 4.223 secs                                                                     06.046684
ox-pandoc                      finished             ✓ 3.836 secs                                                                     06.049230
ht                             finished             ✓ 0.000 secs                                                                     06.049231
org-appear                     finished             ✓ 3.837 secs                                                                     06.050589
deadgrep                       finished             ✓ 3.839 secs                                                                     06.053082
spinner                        finished             ✓ 0.001 secs                                                                     06.053084
undo-fu                        finished             ✓ 3.840 secs                                                                     06.054134
undo-fu-session                finished             ✓ 3.840 secs                                                                     06.055287
super-save                     finished             ✓ 3.842 secs                                                                     06.056682
rainbow-delimiters             finished             ✓ 3.842 secs                                                                     06.057933
expreg                         finished             ✓ 3.843 secs                                                                     06.059317
avy                            finished             ✓ 3.844 secs                                                                     06.060587
ace-window                     finished             ✓ 3.845 secs                                                                     06.061762
corfu                          finished             ✓ 3.845 secs                                                                     06.063043
corfu-english-helper           finished             ✓ 3.846 secs                                                                     06.064402
google-translate               finished             ✓ 3.849 secs                                                                     06.066953
popup                          finished             ✓ 0.001 secs                                                                     06.066955
flyspell-correct               finished             ✓ 3.825 secs                                                                     06.068103
flyspell-correct-avy-menu      finished             ✓ 3.827 secs                                                                     06.070398
avy-menu                       finished             ✓ 0.001 secs                                                                     06.070400
transient                      finished             ✓ 3.831 secs                                                                     06.074555
magit                          finished             ✓ 3.872 secs                                                                     06.115458
with-editor                    finished             ✓ 0.002 secs                                                                     06.115460
posframe                       finished             ✓ 3.873 secs                                                                     06.116753
xr                             finished             ✓ 0.001 secs                                                                     06.119028
pyim                           finished             ✓ 3.877 secs                                                                     06.120914
async                          finished             ✓ 0.002 secs                                                                     06.120915
pyim-basedict                  finished             ✓ 3.877 secs                                                                     06.121925
page-break-lines               finished             ✓ 3.878 secs                                                                     06.123207
dape                           finished             ✓ 3.880 secs                                                                     06.124904
treesit-fold                   finished             ✓ 3.881 secs                                                                     06.126189
indent-bars                    finished             ✓ 3.882 secs                                                                     06.127394
eldoc-box                      finished             ✓ 3.868 secs                                                                     06.128835
eglot-booster                  finished             ✓ 3.869 secs                                                                     06.130188
eglot-inactive-regions         finished             ✓ 3.870 secs                                                                     06.131556
rust-mode                      finished             ✓ 3.871 secs                                                                     06.132838
cargo                          finished             ✓ 3.875 secs                                                                     06.136643
markdown-mode                  finished             ✓ 3.872 secs                                                                     06.136645
tempel                         finished             ✓ 3.875 secs                                                                     06.137856
tempel-collection              finished             ✓ 3.876 secs                                                                     06.138941
eglot-tempel                   finished             ✓ 3.878 secs                                                                     06.140737
annotate                       finished             ✓ 3.879 secs                                                                     06.142179
markdown-toc                   finished             ✓ 3.879 secs                                                                     06.143423
string-inflection              finished             ✓ 3.880 secs                                                                     06.144746
crdt                           finished             ✓ 3.882 secs                                                                     06.146717
telega                         finished             ✓ 3.884 secs                                                                     06.149524
visual-fill-column             finished             ✓ 0.001 secs                                                                     06.149526
svg-lib                        finished             ✓ 0.001 secs                                                                     06.152252
taxy-magit-section             finished             ✓ 0.003 secs                                                                     06.154417
taxy                           finished             ✓ 0.003 secs                                                                     06.154424
plz                            finished             ✓ 0.004 secs                                                                     06.155485
ement                          finished             ✓ 3.892 secs                                                                     06.157623
persist                        finished             ✓ 0.006 secs                                                                     06.157629
emms                           finished             ✓ 3.894 secs                                                                     06.159934
gptel                          finished             ✓ 3.895 secs                                                                     06.161973
eca                            finished             ✓ 0.179 secs                                                                     06.163336
tabnine                        finished             ✓ 0.181 secs                                                                     06.166028
language-id                    finished             ✓ 0.001 secs                                                                     06.166030
copilot                        finished             ✓ 0.182 secs                                                                     06.167339
term-keys                      finished             ✓ 0.183 secs                                                                     06.168502

In these packages, just adding tabnine or deleting tabnine can reproduce/solve Error reading melpa.eld into memory

ISouthRain avatar Oct 23 '25 00:10 ISouthRain

No luck reproducing this on my end yet. Do you have a link to your init files? I'd be happy to take a look and see if I can reproduce with the same set of files.

progfolio avatar Oct 24 '25 01:10 progfolio

This is troublesome. My configurations are all customized by me and are not convenient for sharing.

Is there any good way?

I do it at the beginning of eraly-init.el

(toggle-debug-on-error)
Debugger entered--Lisp error: (invalid-read-syntax "# " 1 797912)
  read(#<buffer  elpaca--read-file>)
  elpaca--read-file("c:/Users/adminuirs/AppData/Roaming/.emacs.d/elpaca/cache/melpa.eld")
  byte-code("\301\302\303\10\"!\207" [elpaca-cache-directory elpaca--read-file expand-file-name "melpa.eld"] 4)
  (defvar elpaca-menu-melpa--index-cache (byte-code "\301\302\303\10\"!\207" [elpaca-cache-directory elpaca--read-file expand-file-name "melpa.eld"] 4) "MELPA recipe cache.")
  elpaca-menu-melpa(index tabnine)
  elpaca-menu-item(tabnine)
  elpaca-recipe(tabnine)
  elpaca<-create(tabnine)
  elpaca--queue(tabnine (elpaca-q init 1 0 incomplete ... nil ... ...))
  elpaca--expand-declaration(tabnine ((defvar use-package--warning108 #'(lambda (keyword err) (let ((msg ...)) (display-warning 'use-package msg :error)))) (condition-case-unless-debug err (progn (unless (fboundp 'tabnine-mode) (autoload #'tabnine-mode "tabnine" nil t)) (condition-case-unless-debug err (progn (setq tabnine-binaries-folder "~/.emacs.d.cache/.TabNine") (setq tabnine-executable-args (list "--log-level" "Error" "--no-lsp" "false"))) (error (funcall use-package--warning108 :init err))) (add-hook 'c-mode-hook #'tabnine-mode) (add-hook 'c-ts-mode-hook #'tabnine-mode) (add-hook 'c++-mode-hook #'tabnine-mode) (add-hook 'c++-ts-mode-hook #'tabnine-mode) (add-hook 'rust-mode-hook #'tabnine-mode) (add-hook 'rust-ts-mode-hook #'tabnine-mode) (add-hook 'tabnine-mode-hook #'(lambda nil (setopt tabnine-completion-map ...)))) (error (funcall use-package--warning108 :catch err)))))
  load-with-code-conversion("c:/Users/adminuirs/AppData/Roaming/.freedom.d/config-elpaca.el" "c:/Users/adminuirs/AppData/Roaming/.freedom.d/config-elpaca.el" nil nil)
  load-file("c:/Users/adminuirs/AppData/Roaming/.freedom.d/config-elpaca.el")
  (if (file-exists-p (expand-file-name "~/.freedom.d/config-elpaca.el")) (load-file (expand-file-name "~/.freedom.d/config-elpaca.el")) (org-babel-load-file (expand-file-name "~/.freedom.d/config-elpaca.org")))
  load-with-code-conversion("c:/Users/adminuirs/AppData/Roaming/.emacs.d/init.el" "c:/Users/adminuirs/AppData/Roaming/.emacs.d/init.el" t t)
  load("c:/Users/adminuirs/AppData/Roaming/.emacs.d/init" noerror nomessage)
  #f(compiled-function () #<bytecode 0xae015a5984455c9>)()
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x427d701215b53d3>) #f(compiled-function () #<bytecode 0x731910ef955a65b>) t)
  command-line()
  normal-top-level()

ISouthRain avatar Oct 24 '25 01:10 ISouthRain

This is troublesome. My configurations are all customized by me and are not convenient for sharing.

Uploading them to a git repository is the typical way. If you're not comfortable sharing them, that's fine. It may be awhile before I can dive into this on a proper Windows set up, though.

progfolio avatar Oct 29 '25 00:10 progfolio