abougouffa / minemacs

MinEmacs: an Emacs configuration framework for daily use
https://abougouffa.github.io/minemacs/
MIT License
143 stars 16 forks source link

Errors "Given parent class emacsql-sqlite-connection is not a class" when using magit #49

Closed mandarvaze closed 1 year ago

mandarvaze commented 1 year ago

I updated to latest version, followed by make clean_all prune

I liked the new Dashboard 😄

The error may be related to external packages (or not)

I faced this issue on both of my macOS machine (One Intel, other M2)

I searched without much luck, except https://github.com/magit/emacsql - but nothing actionable

Any suggestions ?

donneyluck commented 1 year ago

your emacs version on my linux & emacs 28.2 with native every thing ok you can try make clean & make prune reinstall minemacs

abougouffa commented 1 year ago

Try to add this to your config.el

(when (+emacs-features-p 'sqlite3)
  (use-package emacsql-sqlite-builtin
    :straight t
    :after magit
    :demand t))
mandarvaze commented 1 year ago

your emacs version on my linux & emacs 28.2 with native every thing ok you can try make clean & make prune reinstall minemacs

I'm on GNU Emacs 29.0.60 on macOS monterey - I have emacs-plus from d12frosted But it was working till I got the latest minemacs and make clean_all prune

Not sure what reinstall minemacs means. I have latest code from git.

mandarvaze commented 1 year ago

Try to add this to your config.el

(when (+emacs-features-p 'sqlite3)
  (use-package emacsql-sqlite-builtin
    :straight t
    :after magit
    :demand t))

@abougouffa This did not help :( I tried on both machines (Intel and M2) same result on both machines.

abougouffa commented 1 year ago

Can you launch Emacs with:

MINEMACS_DEBUG=1 emacs

Reproduce the error and share the backtrace.

mandarvaze commented 1 year ago

@abougouffa here you go :

Debugger entered--Lisp error: (error "Given parent class emacsql-sqlite-connection is no...")
  error("Given parent class %S is not a class" emacsql-sqlite-connection)
  #f(compiled-function (cname superclasses slots options) "Define CNAME as a new subclass of SUPERCLASSES.\nSLOTS are the slots residing in that class definition, and OPTIONS\nholds the class options.\nSee `defclass' for more information." #<bytecode -0xc8bdba40179bb6c>)(code-review-db-database (emacsql-sqlite-connection closql-database) ((object-class :initform 'code-review-db-pullreq)) nil)
  apply(#f(compiled-function (cname superclasses slots options) "Define CNAME as a new subclass of SUPERCLASSES.\nSLOTS are the slots residing in that class definition, and OPTIONS\nholds the class options.\nSee `defclass' for more information." #<bytecode -0xc8bdba40179bb6c>) (code-review-db-database (emacsql-sqlite-connection closql-database) ((object-class :initform 'code-review-db-pullreq)) nil))
  eieio-defclass-internal(code-review-db-database (emacsql-sqlite-connection closql-database) ((object-class :initform 'code-review-db-pullreq)) nil)
  byte-code("\300\301\302\303!\"\210\300\304\305\303!\"\210\300\306\304\"\210\307\306\310\311#\210\312\303\313\304#\314\303\315\316\317$\207" [defalias code-review-db-database-p eieio-make-class-predicate code-review-db-database code-review-db-database--eieio-childp eieio-make-child-predicate code-review-db-database-child-p make-obsolete "use (cl-typep ... 'code-review-db-database) instea..." "25.1" define-symbol-prop cl-deftype-satisfies eieio-defclass-internal (emacsql-sqlite-connection closql-database) ((object-class :initform 'code-review-db-pullreq)) nil] 6)
  require(code-review-db)
  load-with-code-conversion("/Users/mandar/.emacs.d/local/straight/build-29.0.6..." "/Users/mandar/.emacs.d/local/straight/build-29.0.6..." nil t)
  require(code-review-github)
  load-with-code-conversion("/Users/mandar/.emacs.d/local/straight/build-29.0.6..." "/Users/mandar/.emacs.d/local/straight/build-29.0.6..." t t)
  require(code-review nil t)
  (not (require 'code-review nil t))
  (if (not (require 'code-review nil t)) (display-warning 'use-package (format "Cannot load %s" 'code-review) :error))
  (prog1 (if (not (require 'code-review nil t)) (display-warning 'use-package (format "Cannot load %s" 'code-review) :error)) (let ((elapsed (float-time (time-subtract (current-time) now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Loading package code-review" elapsed) (message "%s...done" "Loading package code-review"))))
  (let ((now (current-time))) (message "%s..." "Loading package code-review") (prog1 (if (not (require 'code-review nil t)) (display-warning 'use-package (format "Cannot load %s" 'code-review) :error)) (let ((elapsed (float-time (time-subtract (current-time) now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Loading package code-review" elapsed) (message "%s...done" "Loading package code-review")))))
  (progn (let ((custom--inhibit-theme-enable nil)) (if (memq 'use-package custom-known-themes) nil (custom-declare-theme 'use-package 'use-package-theme nil (list)) (enable-theme 'use-package) (setq custom-enabled-themes (remq 'use-package custom-enabled-themes))) (custom-theme-set-variables 'use-package '(code-review-download-dir (concat minemacs-cache-dir "code-review/") nil nil "Customized with use-package code-review") '(code-review-db-database-file (concat minemacs-local-dir "code-review/database.sqlite") nil nil "Customized with use-package code-review") '(code-review-log-file (concat minemacs-local-dir "code-review/code-review-error.log") nil nil "Customized with use-package code-review") '(code-review-auth-login-marker 'forge nil nil "Customized with use-package code-review"))) (condition-case err (progn (eval-after-load 'magit #'(lambda nil (transient-append-suffix 'magit-merge "i" '...))) (eval-after-load 'forge #'(lambda nil (transient-append-suffix 'forge-dispatch "c u" '...)))) ((debug error) (funcall use-package--warning63 :init err))) (let ((now (current-time))) (message "%s..." "Loading package code-review") (prog1 (if (not (require 'code-review nil t)) (display-warning 'use-package (format "Cannot load %s" 'code-review) :error)) (let ((elapsed (float-time (time-subtract ... now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Loading package code-review" elapsed) (message "%s...done" "Loading package code-review"))))))
  (closure (t) nil (progn (let ((custom--inhibit-theme-enable nil)) (if (memq 'use-package custom-known-themes) nil (custom-declare-theme 'use-package 'use-package-theme nil (list)) (enable-theme 'use-package) (setq custom-enabled-themes (remq 'use-package custom-enabled-themes))) (custom-theme-set-variables 'use-package '(code-review-download-dir (concat minemacs-cache-dir "code-review/") nil nil "Customized with use-package code-review") '(code-review-db-database-file (concat minemacs-local-dir "code-review/database.sqlite") nil nil "Customized with use-package code-review") '(code-review-log-file (concat minemacs-local-dir "code-review/code-review-error.log") nil nil "Customized with use-package code-review") '(code-review-auth-login-marker 'forge nil nil "Customized with use-package code-review"))) (condition-case err (progn (eval-after-load 'magit #'(lambda nil (transient-append-suffix ... "i" ...))) (eval-after-load 'forge #'(lambda nil (transient-append-suffix ... "c u" ...)))) ((debug error) (funcall use-package--warning63 :init err))) (let ((now (current-time))) (message "%s..." "Loading package code-review") (prog1 (if (not (require 'code-review nil t)) (display-warning 'use-package (format "Cannot load %s" 'code-review) :error)) (let ((elapsed (float-time ...))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Loading package code-review" elapsed) (message "%s...done" "Loading package code-review")))))))()
  eval-after-load-helper("/Users/mandar/.emacs.d/local/straight/build-29.0.6...")
  do-after-load-evaluation("/Users/mandar/.emacs.d/local/straight/build-29.0.6...")
  require(magit nil t)
  byte-code("\300\301!\210\300\302\303\304#\207" [require evil-collection magit nil t] 4)
  evil-collection-require(magit)
  #f(compiled-function () #<bytecode 0x1d7f1169eea08831>)()
  eval-after-load-helper("/Users/mandar/.emacs.d/local/straight/build-29.0.6...")
  do-after-load-evaluation("/Users/mandar/.emacs.d/local/straight/build-29.0.6...")
  require(magit-repos)
  byte-code("\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\210\300\306!\210\300\307!\210\300\310!\210\300\311\312\313#\210\300\314!\210\315\316\317\320\321DD\322..." [require magit-core magit-diff magit-log magit-wip magit-apply magit-repos git-commit format-spec package nil t with-editor custom-declare-variable magit-openpgp-default-signing-key funcall function #f(compiled-function () #<bytecode 0x19800016fe914>) "Fingerprint of your default Openpgp key used for s..." :package-version (magit . "4.0.0") :group magit-commands :type string] 10)
  require(magit)
  byte-code("\301\302!\210\303\304\305\306\307\310\311\312&\7\210\313\314\315\316\317DD\320\311\304\321\322&\7\210\313\323\315\316\324DD\325\326\327\311\304\321\322\330\331&\13\210\313..." [magit-log-margin--custom-type require magit custom-declare-group magit-status nil "Inspect and manipulate Git repositories." :link (info-link "(magit)Status Buffer") :group magit-modes custom-declare-variable magit-status-mode-hook funcall function #f(compiled-function () #<bytecode 0x19800016fe914>) "Hook run after entering Magit-Status mode." :type hook magit-status-headers-hook #f(compiled-function () #<bytecode -0xc8d0202d0368dc1>) "Hook run to insert headers into the status buffer...." :package-version (magit . "2.1.0") :options (magit-insert-error-header magit-insert-diff-filter-header magit-insert-repo-header magit-insert-remote-header magit-insert-head-branch-header magit-insert-upstream-branch-header magit-insert-push-branch-header magit-insert-tags-header) magit-status-sections-hook #f(compiled-function () #<bytecode -0x8b541719f85e605>) "Hook run to insert sections into a status buffer." (magit . "2.12.0") magit-status-initial-section #f(compiled-function () #<bytecode 0x19800016fe854>) "The section point is placed on when a status buffe..." (magit . "2.90.0") (choice (const :tag "as usual" nil) (repeat (choice (number :tag "nth top-level section") (sexp :tag "section identity")))) magit-status-goto-file-position #f(compiled-function () #<bytecode 0x19800016fe914>) "Whether to go to position corresponding to file po..." (magit . "3.0.0") boolean magit-status-show-hashes-in-headers #f(compiled-function () #<bytecode 0x19800016fe914>) "Whether headers in the status buffer show hashes.\n..." (magit . "2.4.0") magit-status-margin #f(compiled-function () #<bytecode -0xfcd1ba1b70414f>) "Format of the margin in `magit-status-mode' buffer..." (magit . "2.9.0") magit-margin :initialize ...] 20)
  command-execute(magit-status)
mandarvaze commented 1 year ago

As suspected, this is external to minemacs Issue reported on doom emacs as well. See https://github.com/doomemacs/doomemacs/issues/7191

@abougouffa How to pin a package, as suggested in doom issue - with minemacs ?

abougouffa commented 1 year ago

There is no equivalent to :pin in MinEmacs, unless there is an equivalent feature in straight.el that I'm not aware of!

mandarvaze commented 1 year ago

@abougouffa I found https://github.com/radian-software/straight.el#how-do-i-pin-package-versions-or-use-only-tagged-releases - but seems very complicated :)

abougouffa commented 1 year ago

I've found a way to temporary fix this, create a file under ~/.emacs.d/local/straight/versions/default.el with the following content:

(("closql" . "0a7226331ff1f96142199915c0ac7940bac4afdd")
 ("forge" . "ba35ffc9bafc6457cc95633904e53e34e544543f")
 ("code-review" . "26f426e99221a1f9356aabf874513e9105b68140"))
:gamma

Then M-x straight-thaw-versions

abougouffa commented 1 year ago

I've added a keyword :pin-ref as an extension to use-package to facilitate using the wired straight-x way of pinning packages.

Now, a package can be pinned like this:

(use-package closql
  :straight t
  :pin-ref "0a7226331ff1f96142199915c0ac7940bac4afdd")

Then, rerun Emacs, and run M-x straight-x-freeze-versions then M-x straight-x-pull-all.

TLDR; The last commit should fix this issue, you need to update your MinEmacs. You might need to run M-x straight-x-freeze-versions then M-x straight-x-pull-all after launching Emacs.

donneyluck commented 1 year ago

image

mandarvaze commented 1 year ago

I too got bunch of errors when running straight-x-pull-all Trying again - starting with make clean_all prune 🤞

mandarvaze commented 1 year ago

@abougouffa I have latest me-vc - should make clean_all prune followed by starting emacs work ? It isn't. I checked ~/.emacs.d/local/straight/repos/closql - it is NOT the version that is pinned.

mandar in ~/.emacs.d/local/straight/repos/closql on î‚  main took 3s
➜  git show 0a7226331ff1f96142199915c0ac7940bac4afdd
fatal: bad object 0a7226331ff1f96142199915c0ac7940bac4afdd

mandar in ~/.emacs.d/local/straight/repos/closql on î‚  main
✗  git checkout 0a7226331ff1f96142199915c0ac7940bac4afdd
fatal: reference is not a tree: 0a7226331ff1f96142199915c0ac7940bac4afdd
mandarvaze commented 1 year ago

I get the following in *straight-process* buffer

$ cd /Users/mandar/.emacs.d/local/straight/repos/closql/
$ git reset --hard 0a7226331ff1f96142199915c0ac7940bac4afdd

fatal: Could not parse object '0a7226331ff1f96142199915c0ac7940bac4afdd'.

[Return code: 128]
abougouffa commented 1 year ago

Thanks for the feedback.

Should be fixed now!

abougouffa commented 1 year ago

For my case, I need to run straight-x-freeze-versions then straight-x-thaw-pinned-verions then straight-rebuild-all.

mandarvaze commented 1 year ago

@abougouffa I updated minemacs via git pull origin main, then freeze -> thaw as you mentioned above I'm getting same error when I run straight-x-thaw-pinned-verions

BTW, I'm using emacs 29 if it matters

abougouffa commented 1 year ago

@mandarvaze Wired! I'm using the Emacs 29 too.

mandarvaze commented 1 year ago

@abougouffa Did make clean_all prune followed by freeze-n-thaw No error during thaw this time. Now running rebuild-all 🤞

abougouffa commented 1 year ago

By the way, running make prune calls the clean_all rule automatically, so there is no need to call them both ~make clean_all prune~

mandarvaze commented 1 year ago

Finally I can use magit 🎉

Thanks @abougouffa for the patience in debugging and quick fixes.

mandarvaze commented 1 year ago

@abougouffa I think still needs work. On my other machine, I'm again facing issues (during thaw) If I select s - I get similar error for flymake

Screenshot 2023-04-18 at 12 49 48 PM

I tried make prune followed by freeze->thaw multiple times. I'm getting the error from the screenshot.

Stack trace :

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-name-as-directory(nil)
  straight--emacs-dir("straight" "repos" nil)
  apply(straight--emacs-dir "straight" ("repos" nil))
  straight--dir("repos" nil)
  apply(straight--dir "repos" nil)
  straight--repos-dir(nil)
  straight--repository-is-available-p((:type built-in :files ("*" (:exclude ".git")) :repo "emacs-straight/eldoc" :host github :package "eldoc"))
  #f(compiled-function (package) #<bytecode -0x16e6e0f12f072459>)("eldoc")
  straight--map-repos-interactively(#f(compiled-function (package) #<bytecode -0x16e6e0f12f072459>))
  straight-x-thaw-pinned-versions()
  funcall-interactively(straight-x-thaw-pinned-versions)
  command-execute(straight-x-thaw-pinned-versions record)
  execute-extended-command(nil "straight-x-thaw-pinned-versions" "thaw")
  funcall-interactively(execute-extended-command nil "straight-x-thaw-pinned-versions" "thaw")
  command-execute(execute-extended-command)
abougouffa commented 1 year ago

I've faced the same issue in Emacs 28. I managed to solve it by pressing e, removing the flymake directory, then re-run thaw. These are problems related to straight.el, there is nothing I can do to improve this!