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

wrong-type-argument stringp (package-delete . 3) #1613

Closed
manuel-uberti opened this issue Jun 8, 2018 · 13 comments

Comments

@manuel-uberti
Copy link
Contributor

commented Jun 8, 2018

Hi,

with latest ivy/counsel/swiper from MELPA, if I do M-x package-delete RET, I get this:

Debugger entered--Lisp error: (wrong-type-argument stringp (package-delete . 3))
  intern((package-delete . 3))
  #f(compiled-function (cmd) #<bytecode 0x13bbf6d>)((package-delete . 3))
  ivy-call()
  #f(compiled-function (arg1 arg2 &rest rest) "Read a string in the minibuffer, with completion.\n\nPROMPT is a format string, normally ending in a colon and a\nspace; %d anywhere in the string is replaced by the current\nnumber of matching candidates.  For the literal % character,\nescape it with %%. See also `ivy-count-format'.\n\nCOLLECTION is either a list of strings, a function, an alist, or\na hash table.\n\nPREDICATE is applied to filter out the COLLECTION immediately.\nThis argument is for `completing-read' compat.\n\nWhen REQUIRE-MATCH is non-nil, only members of COLLECTION can be\nselected, i.e. custom text.\n\nIf INITIAL-INPUT is not nil, then insert that input in the\nminibuffer initially.\n\nHISTORY is a name of a variable to hold the completion session\nhistory.\n\nKEYMAP is composed with `ivy-minibuffer-map'.\n\nIf PRESELECT is not nil, then select the corresponding candidate\nout of the ones that match the INITIAL-INPUT.\n\nDEF is for compatibility with `completing-read'.\n\nUPDATE-FN is called each time the current candidate(s) is changed.\n\nWhen SORT is t, use `ivy-sort-functions-alist' for sorting.\n\nACTION is a lambda function to call after selecting a result.  It\ntakes a single string argument.\n\nUNWIND is a lambda function to call before exiting.\n\nRE-BUILDER is a lambda function to call to transform text into a\nregex pattern.\n\nMATCHER is to override matching.\n\nDYNAMIC-COLLECTION is a boolean to specify if the list of\ncandidates is updated after each input by calling COLLECTION.\n\nCALLER is a symbol to uniquely identify the caller to `ivy-read'.\nIt is used, along with COLLECTION, to determine which\ncustomizations apply to the current completion session." #<bytecode 0x12927c5>)("M-x " ((org-agenda-list . 1) (amx-mode . 1) (buffer-menu . 1) (woman . 6) (haskell-cabal-mode . 1) (package-delete . 3) (cljr-clean-ns . 20) (dired-du-mode . 7) (version . 2) (sql-postgres . 2) (mu-face-at-point . 2) (prettify-symbols-mode . 2) (shell . 1) (proced . 1) (emacs-uptime . 1) (describe-char . 1) (dired-hide-all . 1) (list-directory . 1) (mu-reset-fonts . 1) (flyspell-buffer . 1) (package-install . 1) (cljr-thread-last-all . 1) (counsel-switch-to-shell-buffer . 1) (projectile-cleanup-known-projects . 1) (cd) (ff) (5x5) (amx) (arp) (dbx) (dig) (erc) (ert) (eww) (ftp) (gdb) (irc) (jdb) (man) (mpc) (pdb) (pwd) (rsh) (sdb) (shx) (xdb) (calc) (diff) (dirs) (ffap) ...) :predicate nil :require-match t :history counsel-M-x-history :action #f(compiled-function (cmd) #<bytecode 0x13bbf6d>) :sort nil :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  apply(#f(compiled-function (arg1 arg2 &rest rest) "Read a string in the minibuffer, with completion.\n\nPROMPT is a format string, normally ending in a colon and a\nspace; %d anywhere in the string is replaced by the current\nnumber of matching candidates.  For the literal % character,\nescape it with %%. See also `ivy-count-format'.\n\nCOLLECTION is either a list of strings, a function, an alist, or\na hash table.\n\nPREDICATE is applied to filter out the COLLECTION immediately.\nThis argument is for `completing-read' compat.\n\nWhen REQUIRE-MATCH is non-nil, only members of COLLECTION can be\nselected, i.e. custom text.\n\nIf INITIAL-INPUT is not nil, then insert that input in the\nminibuffer initially.\n\nHISTORY is a name of a variable to hold the completion session\nhistory.\n\nKEYMAP is composed with `ivy-minibuffer-map'.\n\nIf PRESELECT is not nil, then select the corresponding candidate\nout of the ones that match the INITIAL-INPUT.\n\nDEF is for compatibility with `completing-read'.\n\nUPDATE-FN is called each time the current candidate(s) is changed.\n\nWhen SORT is t, use `ivy-sort-functions-alist' for sorting.\n\nACTION is a lambda function to call after selecting a result.  It\ntakes a single string argument.\n\nUNWIND is a lambda function to call before exiting.\n\nRE-BUILDER is a lambda function to call to transform text into a\nregex pattern.\n\nMATCHER is to override matching.\n\nDYNAMIC-COLLECTION is a boolean to specify if the list of\ncandidates is updated after each input by calling COLLECTION.\n\nCALLER is a symbol to uniquely identify the caller to `ivy-read'.\nIt is used, along with COLLECTION, to determine which\ncustomizations apply to the current completion session." #<bytecode 0x12927c5>) ("M-x " ((org-agenda-list . 1) (amx-mode . 1) (buffer-menu . 1) (woman . 6) (haskell-cabal-mode . 1) (package-delete . 3) (cljr-clean-ns . 20) (dired-du-mode . 7) (version . 2) (sql-postgres . 2) (mu-face-at-point . 2) (prettify-symbols-mode . 2) (shell . 1) (proced . 1) (emacs-uptime . 1) (describe-char . 1) (dired-hide-all . 1) (list-directory . 1) (mu-reset-fonts . 1) (flyspell-buffer . 1) (package-install . 1) (cljr-thread-last-all . 1) (counsel-switch-to-shell-buffer . 1) (projectile-cleanup-known-projects . 1) (cd) (ff) (5x5) (amx) (arp) (dbx) (dig) (erc) (ert) (eww) (ftp) (gdb) (irc) (jdb) (man) (mpc) (pdb) (pwd) (rsh) (sdb) (shx) (xdb) (calc) (diff) (dirs) (ffap) ...) :predicate nil :require-match t :history counsel-M-x-history :action #f(compiled-function (cmd) #<bytecode 0x13bbf6d>) :sort nil :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x))
  ivy-historian--nadvice/ivy-read(#f(compiled-function (arg1 arg2 &rest rest) "Read a string in the minibuffer, with completion.\n\nPROMPT is a format string, normally ending in a colon and a\nspace; %d anywhere in the string is replaced by the current\nnumber of matching candidates.  For the literal % character,\nescape it with %%. See also `ivy-count-format'.\n\nCOLLECTION is either a list of strings, a function, an alist, or\na hash table.\n\nPREDICATE is applied to filter out the COLLECTION immediately.\nThis argument is for `completing-read' compat.\n\nWhen REQUIRE-MATCH is non-nil, only members of COLLECTION can be\nselected, i.e. custom text.\n\nIf INITIAL-INPUT is not nil, then insert that input in the\nminibuffer initially.\n\nHISTORY is a name of a variable to hold the completion session\nhistory.\n\nKEYMAP is composed with `ivy-minibuffer-map'.\n\nIf PRESELECT is not nil, then select the corresponding candidate\nout of the ones that match the INITIAL-INPUT.\n\nDEF is for compatibility with `completing-read'.\n\nUPDATE-FN is called each time the current candidate(s) is changed.\n\nWhen SORT is t, use `ivy-sort-functions-alist' for sorting.\n\nACTION is a lambda function to call after selecting a result.  It\ntakes a single string argument.\n\nUNWIND is a lambda function to call before exiting.\n\nRE-BUILDER is a lambda function to call to transform text into a\nregex pattern.\n\nMATCHER is to override matching.\n\nDYNAMIC-COLLECTION is a boolean to specify if the list of\ncandidates is updated after each input by calling COLLECTION.\n\nCALLER is a symbol to uniquely identify the caller to `ivy-read'.\nIt is used, along with COLLECTION, to determine which\ncustomizations apply to the current completion session." #<bytecode 0x12927c5>) "M-x " ((org-agenda-list . 1) (amx-mode . 1) (buffer-menu . 1) (woman . 6) (haskell-cabal-mode . 1) (package-delete . 3) (cljr-clean-ns . 20) (dired-du-mode . 7) (version . 2) (sql-postgres . 2) (mu-face-at-point . 2) (prettify-symbols-mode . 2) (shell . 1) (proced . 1) (emacs-uptime . 1) (describe-char . 1) (dired-hide-all . 1) (list-directory . 1) (mu-reset-fonts . 1) (flyspell-buffer . 1) (package-install . 1) (cljr-thread-last-all . 1) (counsel-switch-to-shell-buffer . 1) (projectile-cleanup-known-projects . 1) (cd) (ff) (5x5) (amx) (arp) (dbx) (dig) (erc) (ert) (eww) (ftp) (gdb) (irc) (jdb) (man) (mpc) (pdb) (pwd) (rsh) (sdb) (shx) (xdb) (calc) (diff) (dirs) (ffap) ...) :predicate nil :require-match t :history counsel-M-x-history :action #f(compiled-function (cmd) #<bytecode 0x13bbf6d>) :sort nil :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  apply(ivy-historian--nadvice/ivy-read #f(compiled-function (arg1 arg2 &rest rest) "Read a string in the minibuffer, with completion.\n\nPROMPT is a format string, normally ending in a colon and a\nspace; %d anywhere in the string is replaced by the current\nnumber of matching candidates.  For the literal % character,\nescape it with %%. See also `ivy-count-format'.\n\nCOLLECTION is either a list of strings, a function, an alist, or\na hash table.\n\nPREDICATE is applied to filter out the COLLECTION immediately.\nThis argument is for `completing-read' compat.\n\nWhen REQUIRE-MATCH is non-nil, only members of COLLECTION can be\nselected, i.e. custom text.\n\nIf INITIAL-INPUT is not nil, then insert that input in the\nminibuffer initially.\n\nHISTORY is a name of a variable to hold the completion session\nhistory.\n\nKEYMAP is composed with `ivy-minibuffer-map'.\n\nIf PRESELECT is not nil, then select the corresponding candidate\nout of the ones that match the INITIAL-INPUT.\n\nDEF is for compatibility with `completing-read'.\n\nUPDATE-FN is called each time the current candidate(s) is changed.\n\nWhen SORT is t, use `ivy-sort-functions-alist' for sorting.\n\nACTION is a lambda function to call after selecting a result.  It\ntakes a single string argument.\n\nUNWIND is a lambda function to call before exiting.\n\nRE-BUILDER is a lambda function to call to transform text into a\nregex pattern.\n\nMATCHER is to override matching.\n\nDYNAMIC-COLLECTION is a boolean to specify if the list of\ncandidates is updated after each input by calling COLLECTION.\n\nCALLER is a symbol to uniquely identify the caller to `ivy-read'.\nIt is used, along with COLLECTION, to determine which\ncustomizations apply to the current completion session." #<bytecode 0x12927c5>) ("M-x " ((org-agenda-list . 1) (amx-mode . 1) (buffer-menu . 1) (woman . 6) (haskell-cabal-mode . 1) (package-delete . 3) (cljr-clean-ns . 20) (dired-du-mode . 7) (version . 2) (sql-postgres . 2) (mu-face-at-point . 2) (prettify-symbols-mode . 2) (shell . 1) (proced . 1) (emacs-uptime . 1) (describe-char . 1) (dired-hide-all . 1) (list-directory . 1) (mu-reset-fonts . 1) (flyspell-buffer . 1) (package-install . 1) (cljr-thread-last-all . 1) (counsel-switch-to-shell-buffer . 1) (projectile-cleanup-known-projects . 1) (cd) (ff) (5x5) (amx) (arp) (dbx) (dig) (erc) (ert) (eww) (ftp) (gdb) (irc) (jdb) (man) (mpc) (pdb) (pwd) (rsh) (sdb) (shx) (xdb) (calc) (diff) (dirs) (ffap) ...) :predicate nil :require-match t :history counsel-M-x-history :action #f(compiled-function (cmd) #<bytecode 0x13bbf6d>) :sort nil :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x))
  ivy-read("M-x " ((org-agenda-list . 1) (amx-mode . 1) (buffer-menu . 1) (woman . 6) (haskell-cabal-mode . 1) (package-delete . 3) (cljr-clean-ns . 20) (dired-du-mode . 7) (version . 2) (sql-postgres . 2) (mu-face-at-point . 2) (prettify-symbols-mode . 2) (shell . 1) (proced . 1) (emacs-uptime . 1) (describe-char . 1) (dired-hide-all . 1) (list-directory . 1) (mu-reset-fonts . 1) (flyspell-buffer . 1) (package-install . 1) (cljr-thread-last-all . 1) (counsel-switch-to-shell-buffer . 1) (projectile-cleanup-known-projects . 1) (cd) (ff) (5x5) (amx) (arp) (dbx) (dig) (erc) (ert) (eww) (ftp) (gdb) (irc) (jdb) (man) (mpc) (pdb) (pwd) (rsh) (sdb) (shx) (xdb) (calc) (diff) (dirs) (ffap) ...) :predicate nil :require-match t :history counsel-M-x-history :action #f(compiled-function (cmd) #<bytecode 0x13bbf6d>) :sort nil :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  call-interactively(counsel-M-x nil nil)
  command-execute(counsel-M-x)

Some details about my environment:

GNU Emacs 27.0.50 (build 1, x86_64-debian-linux-gnu, GTK+ Version 3.22.30)
 of 2018-06-08

Repository revision: 416ba369c4ee2592d226eef68aeb4ad35ffea61d
Configured using:
--host=x86_64-debian-linux-gnu

Emacs uptime: 1 minute, 29 seconds
Colour theme: sanityinc-tomorrow-night
Operating system: Ubuntu 18.04 LTS
Window system: x11
Desktop environment: GNOME Shell 3.28.1

The same command works if I do:

  • emacs -Q
  • M-x package-initialize
  • M-x package-delete RET
@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jun 8, 2018

  1. make plain
  2. M-xpackage-deleteRET

This gives me no error with latest Swiper checkout a05b2bc and Emacs versions

In GNU Emacs 26.1.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2018-06-03 built on thunk
Repository revision: 16e8541b743a6beb1926fef53cf1bfaed9c346db
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description:	Debian GNU/Linux testing (buster)

and

In GNU Emacs 27.0.50 (build 10, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2018-06-04 built on thunk
Repository revision: 1dafa4a02ed45bb4d02c6dc34c55518858422088
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Debian GNU/Linux buster/sid

The error you are getting sounds like those in #1565 and #1567, which were supposed to be fixed by #1568. Have you tried reinstalling Ivy to make sure you include that fix?

If you already have the fix in #1568, then I suspect a bug in historian.el.

@manuel-uberti

This comment has been minimized.

Copy link
Contributor Author

commented Jun 8, 2018

I reinstalled ivy and disabled ivy-historian, but I am still getting the same error.

@ryankask

This comment has been minimized.

Copy link

commented Jun 8, 2018

This is happening to me to as well. Could it be something in 4e3eaf4?

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jun 8, 2018

I'm currently AFK, but if you're sure it's not the doing of historian or ivy-historian, then I suspect the recently added amx support might be to blame, since I don't have it installed and thus wouldn't be affected by it (package-initialize, which is also called by make plain, results in an "impure" environment).

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jun 8, 2018

I'll hopefully get a chance to look at this before 01:00 UTC+3, if no-one beats me to it.

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jun 8, 2018

@ryankask Sorry, didn't see your message. Yes, I suspect so. I don't have either smex or amx installed so I was relying on the logic by @Ergus.

@ryankask

This comment has been minimized.

Copy link

commented Jun 8, 2018

I saw that commit and hadn't heard of amx so I gave it a try but now that's coming up. I've reverted to the previous version of counsel.el and it's working.

@Ergus

This comment has been minimized.

Copy link
Contributor

commented Jun 8, 2018

Hi:
Now I updated counsel and I'm getting the error when calling any command a second time.
(for example package-list-packages):
Wrong type argument: stringp, (package-list-packages . 1)
the first time I use it, the command executes right. The problem only appears when the command was introduced once and I want to reuse it. (typing or arrow+enter)
I have amx and with the initial code and some first corrections from @basil-conto it was working for me.
But if I move back to smex and remove amx, it is working properly and smex completion works as expected.
Sorry for asking for a feature that only created problems for you. I just thought that it could be useful to keep counsel compatible with newer/supported packages.

@manuel-uberti

This comment has been minimized.

Copy link
Contributor Author

commented Jun 8, 2018

Yes, I can confirm it is related to the latest amx support. I removed amx entirely and I can use package-delete with no issues.

@Ergus

This comment has been minimized.

Copy link
Contributor

commented Jun 8, 2018

I found a solution, the problem was that we were using the amx-cache that has the same format than smex-cache, but the ivy-read expects just a list of strings like smex-ido-cache; but this variable was deleted in amx. So I propose to do the formatting on the fly.
This is in fact what smex does; it updates both variables every time. Pull-request #1615

@abo-abo abo-abo closed this in 1355542 Jun 8, 2018

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Jun 8, 2018

@Ergus thanks, just merged.

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jun 9, 2018

ivy-read expects just a list of strings like smex-ido-cache

No, ivy-read is a drop-in replacement for completing-read, which accepts lists of strings, alists with either string or symbol keys, hash tables, and ternary functions. Quoth (elisp) Basic Completion:

If COLLECTION is a list, the permissible completions are specified
by the elements of the list, each of which should be either a
string, or a cons cell whose CAR is either a string or a symbol (a
symbol is converted to a string using ‘symbol-name’).  If the list
contains elements of any other type, those are ignored.

The problem lies in the default :action for counsel-M-x:

swiper/counsel.el

Lines 872 to 873 in 1355542

:action (lambda (cmd)
(setq cmd (intern cmd))

Here, the type and value of CMD depends on the format of the initial collection. If the collection is an alist, then CMD will be a cons. Otherwise, it will be a string. For example, executing the following:

(ivy-read "" '((a . 1)
	       (b . 2)
	       (c . 3))
	  :action (lambda (x)
		    (message "`%S'" x)))

prints ‘(a . 1)’. So another solution would be to change the :action function to accept either a string or a cons cell, but tranforming amx-cache in counsel--M-x-externs (as per #1615) has the benefit that all possible collection sources (amx-cache, smex-ido-cache, and obarray) result in the same type of :action candidate.

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Jun 11, 2018

@basil-conto Thanks for the insight.

basil-conto added a commit to basil-conto/swiper that referenced this issue Aug 7, 2018
counsel.el (counsel--M-x-externs): Touch-up
Document return value format and reformat amx-cache transformation.

Re: abo-abo#1613, abo-abo#1614, abo-abo#1615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.