Fedora下Emacs安装Flycheck遇问题求助:无package-install等命令
Hey there, let's get this sorted out—no need to spend more hours stuck on this! Let's break down the problems you're facing and fix them step by step:
1. Stop modifying system-wide Emacs files first
You mentioned editing /usr/share/emacs/site-lisp/site-start.d/desktop-entry-mode-init.el—don't do that! System files get overwritten when Emacs or Fedora updates, and your changes will be lost. All your personal Emacs config should live in your user directory, which is why we'll create your own init file next.
2. Create your personal Emacs init file
The ~/.emacs.d/init.el file doesn't exist by default—you have to make it yourself. Open a terminal and run this command to create it:
touch ~/.emacs.d/init.el
This will create an empty init file where you can safely add all your custom configurations.
3. Enable package.el (so you can use package-install/list-packages)
Fedora's default Emacs setup might not have package.el (the built-in package manager) enabled out of the box. Add these lines to your new ~/.emacs.d/init.el file to set it up:
;; Enable package.el (require 'package) ;; Add package repositories (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t) ;; Initialize package.el (package-initialize) ;; Refresh package contents if needed (unless package-archive-contents (package-refresh-contents))
Save the file, then restart Emacs. Now when you press Alt-x (or ESC : followed by the command name), you should see package-install and list-packages available.
4. Install Flycheck
Once package.el is working, installing Flycheck is straightforward:
- Press
Alt-x, typepackage-install, hit Enter. - When prompted, type
flycheckand hit Enter. Emacs will download and install the package for you.
Alternatively, you can use list-packages:
- Press
Alt-x, typelist-packages, hit Enter. - Search for
flycheck(useC-sto search), mark it for installation withi, then pressxto execute the installation.
5. Enable Flycheck automatically
To make sure Flycheck starts every time you open Emacs, add these lines to your ~/.emacs.d/init.el file:
;; Enable Flycheck globally (require 'flycheck) (add-hook 'after-init-hook #'global-flycheck-mode)
Save the file and restart Emacs—Flycheck should now be active whenever you open a supported file type (like Python, JavaScript, etc.).
That should get you up and running with Flycheck! Let me know if you run into any snags along the way.
内容的提问来源于stack exchange,提问作者Jose Luis Flores Aguirre

