purcell / flycheck-package

Flycheck checker for elisp package metadata
40 stars 3 forks source link

flycheck-package.elc failed to define function flycheck-package-mode #9

Open amano-kenji opened 1 year ago

amano-kenji commented 1 year ago

If I execute M-x flycheck-mode RET in an emacs lisp buffer, I see this error message.

run-hooks: Autoloading file /home/user/.emacs.d/elpa/flycheck-package-20210509.2325/flycheck-package.elc failed to define function flycheck-package-mode

flycheck-package configuration

(use-package flycheck-package
  :config
  (eval-after-load 'flycheck
    '(flycheck-package-setup)) 
  :hook (emacs-lisp-mode . #'flycheck-mode))
purcell commented 1 year ago

Well yes, this is to be expected: there is no such thing as flycheck-package-mode!

Perhaps you have an autoload which refers to this non-existent mode?

amano-kenji commented 1 year ago
(use-package flycheck-package
  :config
  (eval-after-load 'flycheck
    '(flycheck-package-setup)) 
  :hook (emacs-lisp-mode . #'flycheck-mode))

This is everything I have regarding flycheck-package.

purcell commented 1 year ago

But clearly somewhere in your config or packages is a reference to flycheck-package-mode. Perhaps you referenced it in a previous version of your use-package form, and haven't restarted Emacs since?

amano-kenji commented 1 year ago

I deleted ~/.emacs.d and restarted emacs. I see the same error again.

amano-kenji commented 1 year ago

If I just put (use-package flycheck-package) in ~/.emacs.el and manually execute

in an emacs lisp package. I don't see any error message.

amano-kenji commented 1 year ago

Replacing

(use-package flycheck-package
  :config
  (eval-after-load 'flycheck
    '(flycheck-package-setup)) 
  :hook (emacs-lisp-mode . #'flycheck-mode))

with

(use-package flycheck-package
  :hook ((emacs-lisp-mode . (lambda ()
                              (flycheck-mode)
                              (flycheck-package-setup)))))

eliminates the error. What went wrong? I have to admit that I don't know much about emacs lisp.

amano-kenji commented 1 year ago

With

(use-package flycheck-package
  :hook ((emacs-lisp-mode . (lambda ()
                              (flycheck-mode)
                              (flycheck-package-setup)))))

I see

The first line should be of the form: ";;; package --- Summary"
You should have a section marked ";;; Commentary:"
You should have a section marked ";;; Code:"

in ~/.emacs.el, but ~/.emacs.el is not a package.

purcell commented 1 year ago

What went wrong?

No idea, sorry. The first version of your config snippet is actually more correct, because flycheck-package-setup should be called once, not every time you enter emacs-lisp-mode.

The first line should be of the form: ";;; package --- Summary" You should have a section marked ";;; Commentary:" You should have a section marked ";;; Code:"

Are you using an old version of package-lint perhaps? The wording of these messages are different these days. Perhaps you can share the versions of your emacs and the flycheck, package-lint and flycheck-package packages?

but ~/.emacs.el is not a package.

Perhaps you have a Package-Version, Version or Package-Requires header there? If so, that's taken as an indication that you intend the code to be a package. (This changed at some point, so again, package versions are relevant here.)

amano-kenji commented 1 year ago
(use-package flycheck-package
  :config
  (eval-after-load 'flycheck
    '(flycheck-package-setup))
  :hook (emacs-lisp-mode . flycheck-mode))

instead of

(use-package flycheck-package
  :config
  (eval-after-load 'flycheck
    '(flycheck-package-setup))
  :hook (emacs-lisp-mode . #'flycheck-mode))

also fixed the error. But, I still see

The first line should be of the form: ";;; package --- Summary" You should have a section marked ";;; Commentary:" You should have a section marked ";;; Code:"

in ~/.emacs.el which is a symlink to a file outside home directory.

Perhaps you have a Package-Version, Version or Package-Requires header there?

No, I don't have anything like that in ~/.emacs.el.

Perhaps you can share the versions of your emacs and the flycheck, package-lint and flycheck-package packages?