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

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

Open
amano-kenji opened this issue Mar 6, 2023 · 9 comments

Comments

@amano-kenji
Copy link

amano-kenji commented Mar 6, 2023

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
Copy link
Owner

purcell commented Mar 6, 2023

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
Copy link
Author

(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
Copy link
Owner

purcell commented Mar 7, 2023

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
Copy link
Author

amano-kenji commented Mar 7, 2023

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

@amano-kenji
Copy link
Author

amano-kenji commented Mar 7, 2023

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

  • M-x flycheck-mode RET
  • M-x flycheck-package-setup RET

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

@amano-kenji
Copy link
Author

amano-kenji commented Mar 7, 2023

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
Copy link
Author

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
Copy link
Owner

purcell commented Mar 7, 2023

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
Copy link
Author

amano-kenji commented Mar 8, 2023

(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?

  • flycheck-20230306.414
  • package-lint-20221003.1636
  • flycheck-package-20210509.2325

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