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

Backtrace when upgrading to 0.10.0 #1406

Closed
skangas opened this issue Oct 5, 2023 · 10 comments
Closed

Backtrace when upgrading to 0.10.0 #1406

skangas opened this issue Oct 5, 2023 · 10 comments

Comments

@skangas
Copy link
Contributor

skangas commented Oct 5, 2023

Output of the command M-x company-diag

Emacs 30.0.50 (x86_64-apple-darwin21.6.0) of 2023-10-03 on Newton.local
Company 0.9.13

company-backends: (company-bbdb company-eclim company-semantic company-clang company-xcode
company-cmake company-capf company-files
(company-dabbrev-code company-gtags company-etags company-keywords)
company-oddmuse company-dabbrev)

Used backend: company-dabbrev

Major mode: fundamental-mode
Prefix: nil

Completions: none

Describe the issue

I got a backtrace when upgrading from 0.9.13 to 0.10.0.

Steps to reproduce

Go to the *Packages* buffer, hit U, then x, then y.

Expected behavior

The package upgrades fine.

The error backtrace

Debugger entered--Lisp error: (void-function company-keymap--unbind-quick-access)
  (company-keymap--unbind-quick-access company-active-map)
  (progn (company-keymap--unbind-quick-access company-active-map))
  (if (boundp 'company-active-map) (progn (company-keymap--unbind-quick-access company-active-map)))
  company-custom--set-quick-access(company-quick-access-keys ("1" "2" "3" "4" "5" "6" "7" "8" "9" "0"))
  custom-initialize-reset(company-quick-access-keys (funcall #'(closure (t) nil "" '("1" "2" "3" "4" "5" "6" "7" "8" "9" "0"))))
  custom-declare-variable(company-quick-access-keys (funcall #'(closure (t) nil "" '("1" "2" "3" "4" "5" "6" "7" "8" "9" "0"))) "Character strings used as a part of quick-access key sequences.\nTo change this value without Customize interface, use `customize-set-variable'.\n\nTo change the quick-access key sequences modifier, customize\n`company-quick-access-modifier'.\n\nIf `company-show-quick-access' is non-nil, show quick-access hints\nbeside the candidates." :set company-custom--set-quick-access :type (choice (const :tag "Digits" ("1" "2" "3" "4" "5" "6" "7" "8" "9" "0")) (const :tag "QWERTY home row" ("a" "s" "d" "f" "g" "h" "j" "k" "l" ";")) (repeat :tag "User defined" string)) :package-version (company . "0.9.14"))
  eval-buffer(#<buffer  *load*> nil "/Users/foo/.emacs.d/elpa/company-0.10.0/company.el" nil t)  ; Reading at buffer position 30584
  load-with-code-conversion("/Users/foo/.emacs.d/elpa/company-0.10.0/company.el" "/Users/foo/.emacs.d/elpa/company-0.10.0/company.el" nil t)
  load("/Users/foo/.emacs.d/elpa/company-0.10.0/company" nil t)
  #f(compiled-function (c) #<bytecode -0x142f67cba605255a>)(("/Users/foo/.emacs.d/elpa/company-0.10.0/company" . 423))
  mapc(#f(compiled-function (c) #<bytecode -0x142f67cba605255a>) (("/Users/foo/.emacs.d/elpa/company-0.10.0/company" . 423) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-bbdb" . 424) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-template" . 425) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-semantic" . 427) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-clang" . 428) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-cmake" . 430) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-capf" . 431) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-files" . 432) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-dabbrev" . 433) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-dabbrev-code" . 434) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-gtags" . 435) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-etags" . 438) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-keywords" . 439) ("/Users/foo/.emacs.d/elpa/company-0.10.0/company-oddmuse" . 440)))
  package--reload-previously-loaded(#s(package-desc :name company :version (0 10 0) :summary "Modular text completion framework" :reqs ((emacs (25 1))) :kind nil :archive nil :dir "/Users/foo/.emacs.d/elpa/company-0.10.0" :extras ((:url . "http://company-mode.github.io/") (:keywords "abbrev" "convenience" "matching") (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:commit . "b59662293cc9bd52bf6c7a4c3f70393351b52d71")) :signed nil))
  package-activate-1(#s(package-desc :name company :version (0 10 0) :summary "Modular text completion framework" :reqs ((emacs (25 1))) :kind nil :archive nil :dir "/Users/foo/.emacs.d/elpa/company-0.10.0" :extras ((:url . "http://company-mode.github.io/") (:keywords "abbrev" "convenience" "matching") (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:commit . "b59662293cc9bd52bf6c7a4c3f70393351b52d71")) :signed nil) :reload :deps)
  package-unpack(#s(package-desc :name company :version (0 10 0) :summary "Modular text completion framework" :reqs ((emacs (25 1))) :kind tar :archive "gnu" :dir nil :extras ((:url . "http://company-mode.github.io/") (:keywords "abbrev" "convenience" "matching") (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:commit . "b59662293cc9bd52bf6c7a4c3f70393351b52d71")) :signed nil))
  #f(compiled-function (&optional good-sigs) #<bytecode -0x1d5edc837690b49a>)((#s(epg-signature :status good :key-id "066DAFCB81E42C40" :validity undefined :fingerprint "C433554766D3DDC64221BFAA066DAFCB81E42C40" :creation-time 1696453502 :expiration-time nil :pubkey-algorithm 1 :digest-algorithm 10 :class 0 :version 4 :notations nil) #s(epg-signature :status good :key-id "645357D2883A0966" :validity undefined :fingerprint "0327BE68D64D9A1A66859F15645357D2883A0966" :creation-time 1696453502 :expiration-time nil :pubkey-algorithm 22 :digest-algorithm 8 :class 0 :version 4 :notations nil)))
  #f(compiled-function () #<bytecode 0xd46c40139ac4f77>)()
  package--with-response-buffer-1("https://elpa.gnu.org/packages/" #f(compiled-function () #<bytecode 0xd46c40139ac4f77>) :file "company-0.10.0.tar.sig" :async nil :error-function #f(compiled-function () #<bytecode -0x178c06c82ac9d921>) :noerror t)
  package--check-signature("https://elpa.gnu.org/packages/" "company-0.10.0.tar" "company-0.10.0/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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00014400613451\000014751\0 0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ustar  \0elpa\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0elpa\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0;;; company-clang.el --- company-mode completion backend for Clang  -*- lexical-binding: t -*-\n\n;; Copyright (C) 2009-2011, 2013-2023  Free Software Foundation, Inc.\n\n;; Author: Nikolaj Schumacher\n\n;; This file is part of GNU Emacs.\n\n;; GNU Emacs is free software: you can redistribute it and/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; GNU Emacs is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.\n\n\n;;; Commentary:\n;;\n\n;;; Code:\n\n(require 'company)\n(require 'company-template)\n(require 'cl-lib)\n\n(defgroup company-clang nil\n  \"Completion backend for Clang.\"\n  :group 'company)\n\n(defcustom company-clang-executable\n  (executable-find \"clang\")\n  \"Location of clang executable.\"\n  :type 'file)\n\n(defcustom company-clang-begin-after-member-access t\n  \"When non-nil, start automatic completion after member access operators.\n\nAutomatic completion starts whenever the current symbol is preceded by\n\\\".\\\", \\\"->\\\" or \\\"::\\\", ignoring `company-minimum-prefix-length'.\n\nIf `company-begin-commands' is a list, it should include `c-electric-lt-gt'\nand `c-electric-colon', for automatic completion right after \\\">\\\" and\n\\\":\\\".\"\n  :type 'boolean)\n\n(defcustom company-clang-use-compile-flags-txt nil\n  \"When non-nil, use flags from compile_flags.txt if present.\n\nThe lines from that files will be appended to `company-clang-arguments'.\n\nAnd if such file is found, Clang is called from the directory containing\nit.  That allows the flags use relative file names within the project.\"\n  :type 'boolean\n  :safe 'booleanp)\n\n(defcustom company-clang-arguments nil\n  \"A list of additional arguments to pass to clang when completing.\nPrefix files (-include ...) can be selected with `company-clang-set-prefix'\nor automatically through a custom `company-clang-prefix-guesser'.\"\n  :type '(repeat (string :tag \"Argument\")))\n\n(defcustom company-clang-prefix-guesser 'company-clang-guess-prefix\n  \"A function to determine the prefix file for the current buffer.\"\n  :type '(function :tag \"Guesser function\" nil))\n\n(defvar company-clang-modes '(c-mode c++-mode objc-mode)\n  \"Major modes which clang may complete.\")\n\n(defcustom company-clang-insert-arguments t\n  \"When non-nil, insert function arguments as a template after completion.\"\n  :type 'boolean\n  :package-..." nil #f(compiled-function (&optional good-sigs) #<bytecode -0x1d5edc837690b49a>))
  #f(compiled-function () #<bytecode -0xd0c892c59cfd79f>)()
  package--with-response-buffer-1("https://elpa.gnu.org/packages/" #f(compiled-function () #<bytecode -0xd0c892c59cfd79f>) :file "company-0.10.0.tar" :async nil :error-function #f(compiled-function () #<bytecode 0x198000153e91>) :noerror nil)
  package-install-from-archive(#s(package-desc :name company :version (0 10 0) :summary "Modular text completion framework" :reqs ((emacs (25 1))) :kind tar :archive "gnu" :dir nil :extras ((:url . "http://company-mode.github.io/") (:keywords "abbrev" "convenience" "matching") (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:commit . "b59662293cc9bd52bf6c7a4c3f70393351b52d71")) :signed nil))
  mapc(package-install-from-archive (#s(package-desc :name company :version (0 10 0) :summary "Modular text completion framework" :reqs ((emacs (25 1))) :kind tar :archive "gnu" :dir nil :extras ((:url . "http://company-mode.github.io/") (:keywords "abbrev" "convenience" "matching") (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:commit . "b59662293cc9bd52bf6c7a4c3f70393351b52d71")) :signed nil)))
  package-download-transaction((#s(package-desc :name company :version (0 10 0) :summary "Modular text completion framework" :reqs ((emacs (25 1))) :kind tar :archive "gnu" :dir nil :extras ((:url . "http://company-mode.github.io/") (:keywords "abbrev" "convenience" "matching") (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:commit . "b59662293cc9bd52bf6c7a4c3f70393351b52d71")) :signed nil)))
  package-install(#s(package-desc :name company :version (0 10 0) :summary "Modular text completion framework" :reqs ((emacs (25 1))) :kind tar :archive "gnu" :dir nil :extras ((:url . "http://company-mode.github.io/") (:keywords "abbrev" "convenience" "matching") (:maintainer "Dmitry Gutov" . "dmitry@gutov.dev") (:commit . "b59662293cc9bd52bf6c7a4c3f70393351b52d71")) :signed nil) dont-select)
  package-menu--perform-transaction((... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (... ... ... ... ... ... ... ... ... ... ... ... ... ... ...))
  package-menu-execute()
  funcall-interactively(package-menu-execute)
  call-interactively(package-menu-execute nil nil)
  command-execute(package-menu-execute)
@dgutov
Copy link
Member

dgutov commented Oct 5, 2023

Ouch.

Does that only happen when upgrading from 0.9.13?

I haven't been able to reproduce so far, but that might be because I haven't had that version installed for a long time. ;(

@dgutov
Copy link
Member

dgutov commented Oct 5, 2023

I've also tried e.g. customizing company-quick-access-keys, then uninstalling the packages (inside a "bare" session), then installing it again. And loading, and using -- no error.

@dgutov
Copy link
Member

dgutov commented Oct 5, 2023

Also tried installing from https://elpa.gnu.org/packages/company-0.9.13.tar.lz (using M-x package-install-file), then customizing company-show-numbers and then upgrading.

@skangas
Copy link
Contributor Author

skangas commented Oct 5, 2023

I can reproduce this in an Emacs session using my init file (i.e. with company-0.9.13) by evaluating:

(load "/Users/foo/.emacs.d/elpa/company-0.10.0/company")

But I can't reproduce it in emacs -Q. I have no idea what might be causing that.

@skangas
Copy link
Contributor Author

skangas commented Oct 5, 2023

Aha, so I can reproduce it in emacs -Q (current master, if it matters) by evaluating:

(progn
  (load "/Users/foo/.emacs.d/elpa/company-0.9.13/company")
  (load "/Users/foo/.emacs.d/elpa/company-0.10.0/company"))

So there does seem to exist some unusual interaction between the two versions.

EDIT: Here's the backtrace:

Debugger entered--Lisp error: (void-function company-keymap--unbind-quick-access)
  (company-keymap--unbind-quick-access company-active-map)
  (progn (company-keymap--unbind-quick-access company-active-map))
  (if (boundp 'company-active-map) (progn (company-keymap--unbind-quick-access company-active-map)))
  company-custom--set-quick-access(company-quick-access-keys ("1" "2" "3" "4" "5" "6" "7" "8" "9" "0"))
  custom-initialize-reset(company-quick-access-keys (funcall #'(closure (t) nil "" '("1" "2" "3" "4" "5" "6" "7" "8" "9" "0"))))
  custom-declare-variable(company-quick-access-keys (funcall #'(closure (t) nil "" '("1" "2" "3" "4" "5" "6" "7" "8" "9" "0"))) "Character strings used as a part of quick-access key sequences.\nTo change this value without Customize interface, use `customize-set-variable'.\n\nTo change the quick-access key sequences modifier, customize\n`company-quick-access-modifier'.\n\nIf `company-show-quick-access' is non-nil, show quick-access hints\nbeside the candidates." :set company-custom--set-quick-access :type (choice (const :tag "Digits" ("1" "2" "3" "4" "5" "6" "7" "8" "9" "0")) (const :tag "QWERTY home row" ("a" "s" "d" "f" "g" "h" "j" "k" "l" ";")) (repeat :tag "User defined" string)) :package-version (company . "0.9.14"))
  eval-buffer(#<buffer  *load*> nil "/Users/foo/.emacs.d/elpa/company-0.10.0/company.el" nil t)  ; Reading at buffer position 30584
  load-with-code-conversion("/Users/foo/.emacs.d/elpa/company-0.10.0/company.el" "/Users/foo/.emacs.d/elpa/company-0.10.0/company.el" nil nil)
  load("/Users/foo/.emacs.d/elpa/company-0.10.0/company")
  (progn (load "/Users/foo/.emacs.d/elpa/company-0.9.13/company") (load "/Users/foo/.emacs.d/elpa/company-0.10.0/company"))
  (progn (progn (load "/Users/foo/.emacs.d/elpa/company-0.9.13/company") (load "/Users/foo/.emacs.d/elpa/company-0.10.0/company")))
  eval((progn (progn (load "/Users/foo/.emacs.d/elpa/company-0.9.13/company") (load "/Users/foo/.emacs.d/elpa/company-0.10.0/company"))) t)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

@dgutov
Copy link
Member

dgutov commented Oct 5, 2023

Okay, I see the problem: inside company-custom--set-quick-access, we expected that if company-active-map is defined, then the function that comes before it, is surely defined too. Could you verify that this patch fixes things?

diff --git a/company.el b/company.el
index 6b00430..ee9cee5 100644
--- a/company.el
+++ b/company.el
@@ -702,15 +702,18 @@ commands in the `company-' namespace, abort completion."
 
 (defun company-custom--set-quick-access (option value)
   "Re-bind quick-access key sequences on OPTION VALUE change."
-  (when (boundp 'company-active-map)
-    (company-keymap--unbind-quick-access company-active-map))
-  (when (boundp 'company-search-map)
-    (company-keymap--unbind-quick-access company-search-map))
+  ;; When upgrading from an earlier version of company, might not be.
+  (when (fboundp #'company-keymap--unbind-quick-access)
+    (when (boundp 'company-active-map)
+      (company-keymap--unbind-quick-access company-active-map))
+    (when (boundp 'company-search-map)
+      (company-keymap--unbind-quick-access company-search-map)))
   (custom-set-default option value)
-  (when (boundp 'company-active-map)
-    (company-keymap--bind-quick-access company-active-map))
-  (when (boundp 'company-search-map)
-    (company-keymap--bind-quick-access company-search-map)))
+  (when (fboundp #'company-keymap--bind-quick-access)
+    (when (boundp 'company-active-map)
+      (company-keymap--bind-quick-access company-active-map))
+    (when (boundp 'company-search-map)
+      (company-keymap--bind-quick-access company-search-map))))
 
 (defcustom company-quick-access-keys '("1" "2" "3" "4" "5" "6" "7" "8" "9" "0")
   "Character strings used as a part of quick-access key sequences.

I still cannot reproduce it myself: with Emacs built either from master or emacs-29 or earlier, the new version is simply not loaded upon installation.

@skangas
Copy link
Contributor Author

skangas commented Oct 5, 2023

Could you verify that this patch fixes things?

I can confirm that the patch fixes the bug.

@dgutov
Copy link
Member

dgutov commented Oct 5, 2023

The last question had a simple answer: the error is inside with-demoted-errors, so I actually experienced it, but it stayed a lonely single line in Messages:

Error in package--load-files-for-activation: (void-function company-keymap--unbind-quick-access)

@skangas Any chance you were running with M-x toggle-debug-on-error in the beginning too?

@dgutov dgutov closed this as completed in d832d88 Oct 5, 2023
@dgutov
Copy link
Member

dgutov commented Oct 5, 2023

I can confirm that the patch fixes the bug

Thanks for verifying, I've tagged a new release.

@skangas
Copy link
Contributor Author

skangas commented Oct 5, 2023

@skangas Any chance you were running with M-x toggle-debug-on-error in the beginning too?

Yes, I was.

Thanks for verifying, I've tagged a new release.

Thanks for the fix!

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