Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disproject commands fail due to possible transient API change #4

Closed
mpereira opened this issue Dec 13, 2024 · 3 comments
Closed

disproject commands fail due to possible transient API change #4

mpereira opened this issue Dec 13, 2024 · 3 comments

Comments

@mpereira
Copy link

mpereira commented Dec 13, 2024

Hi,

Thanks for writing this package, it looks really cool.

I tried using it but running any disproject commands (e.g., M-x disproject-dispatch) shows the error below for me. I suspect it might be due to changes in transient's API.

Please let me know if I can give you more information.

Emacs

GNU Emacs 30.0.92 (build 2, aarch64-apple-darwin24.2.0, NS appkit-2575.30 Version 15.2 (Build 24C101)) of 2024-12-12

disproject

;; Package-Version: 20241211.2257
;; Package-Revision: 58255e214881

transient

;; Package-Version: 20241212.1226
;; Package-Revision: e1126a6ffc25
Debugger entered--Lisp error: (wrong-type-argument listp "/Users/mpereira/.emacs.d/")
  transient--exit-and-debug(error (wrong-type-argument listp "/Users/mpereira/.emacs.d/"))
  car("/Users/mpereira/.emacs.d/")
  #f(compiled-function (obj) "Return the OBJ project backend." #<bytecode -0xc22c6dd8a100079>)(#<disproject-project disproject-project-4e8f2755>)
  apply(#f(compiled-function (obj) "Return the OBJ project backend." #<bytecode -0xc22c6dd8a100079>) #<disproject-project disproject-project-4e8f2755> nil)
  disproject-project-backend(#<disproject-project disproject-project-4e8f2755>)
  disproject-prefix--version-control-apt?()
  transient--do-suffix-p(nil disproject-prefix--version-control-apt? nil nil nil nil nil nil nil)
  transient--inapt-suffix-p(#<transient-suffix transient-suffix-4e8eef2a>)
  transient--init-suffix(nil (1 transient-suffix (:key "v" :command disproject-vc-status :inapt-if-not disproject-prefix--version-control-apt?)) #<transient-column transient-column-4e8f692a>)
  transient--init-child(nil (1 transient-suffix (:key "v" :command disproject-vc-status :inapt-if-not disproject-prefix--version-control-apt?)) #<transient-column transient-column-4e8f692a>)
  #f(compiled-function (c) #<bytecode -0xc1a7f098e34c91a>)((1 transient-suffix (:key "v" :command disproject-vc-status :inapt-if-not disproject-prefix--version-control-apt?)))
  transient--init-group(nil [1 transient-column nil ((1 transient-suffix (:key "b" :description "Switch buffer" :command disproject-switch-to-buffer)) (1 transient-suffix (:key "B" :description "Buffer list" :command disproject-list-buffers)) (1 transient-suffix (:key "c" :command disproject-compile)) (1 transient-suffix (:key "d" :description "Dired" :command disproject-dired)) (1 transient-suffix (:key "k" :description "Kill buffers" :command disproject-kill-buffers)) (1 transient-suffix (:key "l" :description "Dir-locals file" :command disproject-dir-locals)) (1 transient-suffix (:key "s" :description "Shell" :command disproject-shell)) (1 transient-suffix (:key "v" :command disproject-vc-status :inapt-if-not disproject-prefix--version-control-apt?)))] #<transient-columns transient-columns-4e8f662a>)
  transient--init-child(nil [1 transient-column nil ((1 transient-suffix (:key "b" :description "Switch buffer" :command disproject-switch-to-buffer)) (1 transient-suffix (:key "B" :description "Buffer list" :command disproject-list-buffers)) (1 transient-suffix (:key "c" :command disproject-compile)) (1 transient-suffix (:key "d" :description "Dired" :command disproject-dired)) (1 transient-suffix (:key "k" :description "Kill buffers" :command disproject-kill-buffers)) (1 transient-suffix (:key "l" :description "Dir-locals file" :command disproject-dir-locals)) (1 transient-suffix (:key "s" :description "Shell" :command disproject-shell)) (1 transient-suffix (:key "v" :command disproject-vc-status :inapt-if-not disproject-prefix--version-control-apt?)))] #<transient-columns transient-columns-4e8f662a>)
  #f(compiled-function (c) #<bytecode -0xc1a64098e34c91a>)([1 transient-column nil ((1 transient-suffix (:key "b" :description "Switch buffer" :command disproject-switch-to-buffer)) (1 transient-suffix (:key "B" :description "Buffer list" :command disproject-list-buffers)) (1 transient-suffix (:key "c" :command disproject-compile)) (1 transient-suffix (:key "d" :description "Dired" :command disproject-dired)) (1 transient-suffix (:key "k" :description "Kill buffers" :command disproject-kill-buffers)) (1 transient-suffix (:key "l" :description "Dir-locals file" :command disproject-dir-locals)) (1 transient-suffix (:key "s" :description "Shell" :command disproject-shell)) (1 transient-suffix (:key "v" :command disproject-vc-status :inapt-if-not disproject-prefix--version-control-apt?)))])
  transient--init-group(nil [1 transient-columns (:description "Main commands" :pad-keys t) ([1 transient-column nil ((1 transient-suffix (:key "b" :description "Switch buffer" :command disproject-switch-to-buffer)) (1 transient-suffix (:key "B" :description "Buffer list" :command disproject-list-buffers)) (1 transient-suffix (:key "c" :command disproject-compile)) (1 transient-suffix (:key "d" :description "Dired" :command disproject-dired)) (1 transient-suffix (:key "k" :description "Kill buffers" :command disproject-kill-buffers)) (1 transient-suffix (:key "l" :description "Dir-locals file" :command disproject-dir-locals)) (1 transient-suffix (:key "s" :description "Shell" :command disproject-shell)) (1 transient-suffix (:key "v" :command disproject-vc-status :inapt-if-not disproject-prefix--version-control-apt?)))] [1 transient-column nil ((1 transient-suffix (:key "!" :description "Run" :command disproject-shell-command)) (1 transient-suffix (:key "M-x" :description "Extended cmd." :command disproject-execute-extended-command)))] [1 transient-column (:description "Find") ((1 transient-suffix (:key "D" :description "directory" :command disproject-find-dir)) (1 transient-suffix (:key "f" :description "file" :command disproject-find-file)) (1 transient-suffix (:key "F" :description "file (+external)" :command disproject-or-external-find-file)) (1 transient-suffix (:key "g" :description "regexp" :command disproject-find-regexp)) (1 transient-suffix (:key "G" :description "regexp (+external)" :command disproject-or-external-find-regexp)) (1 transient-suffix (:key "L" :description "line occurrence" :command disproject-find-line)) (1 transient-suffix (:key "T" :description "todos" :command disproject-magit-todos-list :if disproject-prefix--magit-todos-apt?)))])] nil)
  transient--init-child(nil [1 transient-columns (:description "Main commands" :pad-keys t) ([1 transient-column nil ((1 transient-suffix (:key "b" :description "Switch buffer" :command disproject-switch-to-buffer)) (1 transient-suffix (:key "B" :description "Buffer list" :command disproject-list-buffers)) (1 transient-suffix (:key "c" :command disproject-compile)) (1 transient-suffix (:key "d" :description "Dired" :command disproject-dired)) (1 transient-suffix (:key "k" :description "Kill buffers" :command disproject-kill-buffers)) (1 transient-suffix (:key "l" :description "Dir-locals file" :command disproject-dir-locals)) (1 transient-suffix (:key "s" :description "Shell" :command disproject-shell)) (1 transient-suffix (:key "v" :command disproject-vc-status :inapt-if-not disproject-prefix--version-control-apt?)))] [1 transient-column nil ((1 transient-suffix (:key "!" :description "Run" :command disproject-shell-command)) (1 transient-suffix (:key "M-x" :description "Extended cmd." :command disproject-execute-extended-command)))] [1 transient-column (:description "Find") ((1 transient-suffix (:key "D" :description "directory" :command disproject-find-dir)) (1 transient-suffix (:key "f" :description "file" :command disproject-find-file)) (1 transient-suffix (:key "F" :description "file (+external)" :command disproject-or-external-find-file)) (1 transient-suffix (:key "g" :description "regexp" :command disproject-find-regexp)) (1 transient-suffix (:key "G" :description "regexp (+external)" :command disproject-or-external-find-regexp)) (1 transient-suffix (:key "L" :description "line occurrence" :command disproject-find-line)) (1 transient-suffix (:key "T" :description "todos" :command disproject-magit-todos-list :if disproject-prefix--magit-todos-apt?)))])] nil)
  #f(compiled-function (c) #<bytecode -0x40d6a9d59dafdbd>)([1 transient-columns (:description "Main commands" :pad-keys t) ([1 transient-column nil ((1 transient-suffix (:key "b" :description "Switch buffer" :command disproject-switch-to-buffer)) (1 transient-suffix (:key "B" :description "Buffer list" :command disproject-list-buffers)) (1 transient-suffix (:key "c" :command disproject-compile)) (1 transient-suffix (:key "d" :description "Dired" :command disproject-dired)) (1 transient-suffix (:key "k" :description "Kill buffers" :command disproject-kill-buffers)) (1 transient-suffix (:key "l" :description "Dir-locals file" :command disproject-dir-locals)) (1 transient-suffix (:key "s" :description "Shell" :command disproject-shell)) (1 transient-suffix (:key "v" :command disproject-vc-status :inapt-if-not disproject-prefix--version-control-apt?)))] [1 transient-column nil ((1 transient-suffix (:key "!" :description "Run" :command disproject-shell-command)) (1 transient-suffix (:key "M-x" :description "Extended cmd." :command disproject-execute-extended-command)))] [1 transient-column (:description "Find") ((1 transient-suffix (:key "D" :description "directory" :command disproject-find-dir)) (1 transient-suffix (:key "f" :description "file" :command disproject-find-file)) (1 transient-suffix (:key "F" :description "file (+external)" :command disproject-or-external-find-file)) (1 transient-suffix (:key "g" :description "regexp" :command disproject-find-regexp)) (1 transient-suffix (:key "G" :description "regexp (+external)" :command disproject-or-external-find-regexp)) (1 transient-suffix (:key "L" :description "line occurrence" :command disproject-find-line)) (1 transient-suffix (:key "T" :description "todos" :command disproject-magit-todos-list :if disproject-prefix--magit-todos-apt?)))])])
  transient--init-suffixes(disproject-dispatch)
  transient--init-objects(disproject-dispatch nil (:value nil))
  transient--init-transient(disproject-dispatch nil (:value nil))
  #f(compiled-function () #<bytecode -0x1b29b7ab140cf99f>)()
  transient--env-apply(#f(compiled-function () #<bytecode -0x1b29b7ab140cf99f>) #<disproject-prefix disproject-prefix-f2328308>)
  transient-setup(disproject-dispatch nil nil :value nil)
  disproject-dispatch()
  funcall-interactively(disproject-dispatch)
  command-execute(disproject-dispatch record)
  #<subr execute-extended-command>(nil "disproject-dispatch" nil)
  ad-Advice-execute-extended-command(#<subr execute-extended-command> nil "disproject-dispatch" nil)
  apply(ad-Advice-execute-extended-command #<subr execute-extended-command> (nil "disproject-dispatch" nil))
  execute-extended-command(nil "disproject-dispatch" nil)
  funcall-interactively(execute-extended-command nil "disproject-dispatch" nil)
  command-execute(execute-extended-command)
@aurtzy
Copy link
Owner

aurtzy commented Dec 13, 2024

Hello, thanks for the kind words :)

I'm unfortunately not able to reproduce this on the latest transient commit.

If I'm reading the error correctly, it looks like the project.el instance being found is just a string; would you happen to have any configurations for the variable project-find-functions? I definitely see a bug with how I'm fetching the backend value, but not sure if it's the one you're encountering yet. What's the value of project-find-functions?

Please try evaluating the following (e.g. by putting it in your scratch buffer and executing M-x eval-buffer):

(cl-defmethod disproject-project-backend ((obj disproject-project))
  "Return the OBJ project backend."
  (if (slot-boundp obj 'backend)
      (oref obj backend)
    (oset obj backend (let ((instance (disproject-project-instance obj)))
                        (if (and (listp instance) (length> instance 1))
                            (nth 1 instance))))))

Does the same error still occur after evaluating this?

It would also help to provide instructions for reproducing this through emacs -Q if the above didn't work.

@mpereira
Copy link
Author

Hi @aurtzy,

Thanks for the super quick reply.

Evaluating the code block you provided fixes the error for me, thanks!

M-x describe-variable project-find-functions

project-find-functions is a variable defined in `project.el'.

Its value is (project-projectile project-try-vc bazel-find-project)

[...]

Let me know if this is enough for you to reproduce. If not, I'll help.

@aurtzy
Copy link
Owner

aurtzy commented Dec 13, 2024

Awesome. Yes, I see what's causing the issue - project-find-functions doesn't enforce a project instance format, so I can't assume the instance returned from that is always going to have the backend in the same place.

project.el doesn't appear to have a generic way to fetch the backend, so - at least for now - I'll have to rely on just project-try-vc and project-vc-backend-markers-alist to determine VCS backends.

Thank you for the report! Will push a fix shortly.

aurtzy added a commit that referenced this issue Dec 13, 2024
This fixes an incorrect assumption that `project-find-functions` always returns
a project instance in a consistent format.  Instead of using
`disproject-project-instance`, we specifically call `project-try-vc` in the root
to get the backend.

Resolves: <#4>
@aurtzy aurtzy closed this as completed Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants