my cheat sheet on emacs packages
1 emacs packages
Most obvious command is M-x list-packages
which shows what is installed.
There is a package called package.el
that is the first package to install
1.1 Install a package
M-x package-install
1.2 Delete a package
M-x package-delete
1.3 Get info on a package
M-x describe-package (C-h P)
1.4 Re-install a package
M-x package-reinstall
1.5 Troubleshooting connectivity
I could not install a package, nor update the list of packages with an error:
"could not contact https://melpa.org/package
The full message in the *Messages buffer was:
Error retrieving: https://elpa.gnu.org/packages/archive-contents \ (error connection-failed "connect" :host "elpa.gnu.org" :service 443)
See fix.
Some tips:
1.5.1 M-x h v package-activated-list
For help on the variable package-activated-list
.
1.5.2
1.5.3 Directories where packagers reside
~/.emacs.d/elpa
for elpa packages~/.emacs.d/elpy
for elpa packages
I don't have a melpa directory. hmmmm…
2 List Pacakges
M-x list-pacages
shows you the list:U
: upgrade packagesi
: install packaged
: delete packageu
: unmark what you previously markedx
: execute the markings you markedhammer
: read more info on the package
2.1 refresh contents
To refresh the package list contents with the latest versions available from your providers:
M-x package-refresh-contents
This is especially useful if you get errors like
file error "https://melpa.org/packages/fooboar-20215151.tar" "Not Found"
It is probably because some internal variables corresponding to the cached list of packages is out of sync.
This is the same as U
from within M-x list-packages
.
3 Saving a list of installed packages
Remembering that M-x list-packages
results in a buffer that is searchable
and is text that can be copied, you can save the list into a buffer that
then is saved as a file.
M-x list-packages
C-s installed
C-SPC
to set markdown
till you have all the installed packages selectedM-x
to copyC-x C-f my-saved-package-list
to open a new file "my-saved-package-list"C-y
to paste the listC-x C-s
to save the file.
Assuming you just select "Install" after selecting a package in
M-x list-packages RET
, you can obtain the list using:
(with-temp-file "packages.txt" (insert (format "%S" package-activated-list)))
4 Automatically Installing list of packages
Apparently use-package
allows you to download missing packages automatically,
so making it easier to sync up two computers to have the same emacs settings.
.i.e. like a laptop and a Linux VM.
From reddit:
All my settings (including my Gnus configuration which is a different thing) are on GitHub and in my Dropbox so I always have them with me. Emacs itself has a package manager which allows me to put these lines into me .emacs:
(setq package-list '( helm twittering-mode ;; (and more packages...) )) (dolist (package package-list) (when (not (package-installed-p package)) (package-install package)))
If a package does not exist on start, Emacs grabs it automatically. So all I need is my .emacs file. #+ENDEXAMPLE
5 Certificates
5.1 Where are they?
Look here:
system | file |
---|---|
linux | /etc/ssl/certs |
mac osx | /etc/ssl/certs |
/usr/local/etc/ca-certificates | |
/usr/local/etc/openssl | |
/usr/local/etc/openssl@1.1 | |
/usr/local/etc/gnutls | |
libressl | /usr/local/etc/libressl/certs |
/etc[3444] $ brew install libressl ==> Downloading https://ghcr.io/v2/homebrew/core/libressl/manifests/3.4.3 ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/libressl/blobs/sha256:579393d... ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh... ######################################################################## 100.0% ==> Pouring libressl--3.4.3.monterey.bottle.tar.gz ==> Regenerating CA certificate bundle from keychain, this may take a while... ==> Caveats A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/libressl/certs and run /usr/local/opt/libressl/bin/openssl certhash /usr/local/etc/libressl/certs libressl is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble. If you need to have libressl first in your PATH, run: echo 'export PATH="/usr/local/opt/libressl/bin:$PATH"' >> ~/.zshrc For compilers to find libressl you may need to set: export LDFLAGS="-L/usr/local/opt/libressl/lib" export CPPFLAGS="-I/usr/local/opt/libressl/include" For pkg-config to find libressl you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/libressl/lib/pkgconfig" ==> Summary 🍺 /usr/local/Cellar/libressl/3.4.3: 3,335 files, 15.8MB ==> Running `brew cleanup libressl`... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). /etc[3445]
- identify what emacs sees as valid path expression by doing a Meta-! pwd. This revealed on my system that - at least this part of emacs - uses the Cygwin paths (I have it installed since the beginning, much earlier than the problems with ELPA, so don't ask me why that turned into a problem suddenly) like cygdrive/c/emacs/bin. Switching package-gnupghome-dir to the respective loacation (/cygdrive/c…/.emacs.d/elpa/gnupg) solved the issue for me. It seems the key there was still valid as I didn't need to refresh it.
(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) ; Bootstrap 'use-package' (eval-after-load 'gnutls '(add-to-list 'gnutls-trustfiles "/etc/ssl/cert.pem")) (unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package)) (eval-when-compile (require 'use-package)) (require 'bind-key) (setq use-package-always-ensure t) ;;}}}
- First we load the package package,
- add MELPA, and
- initialize package.
Then we add certs to gnutls. Next we test if Emacs thinks that use-package is installed, and install it otherwise. Note this is different than just seeing the package on our filesystem or in our load-path.
5.2 to update ca file name ca.cert to /etc/ssl/certs do this:
- copy your certificates inside /etc/pki/ca-trust/source/anchors then run the following command
- update-ca-trust
5.3 Installing ca-certificates
Find *.pem file and place it to the anchors sub-directory or just simply link the *.pem file to there.
- yum install -y ca-certificates
- update-ca-trust force-enable
- sudo ln -s /etc/ssl/your-cert.pem /etc/pki/ca-trust/source/anchors/your-cert.pem
- update-ca-trust
--- QUICK HELP 1: To add a certificate in the simple PEM or DER file formats to the list of CAs trusted on the system: • add it as a new file to directory /etc/pki/ca-trust/source/anchors/ • run update-ca-trust extract QUICK HELP 2: If your certificate is in the extended BEGIN TRUSTED file format (which may contain distrust/blacklist trust flags, or trust flags for usages other than TLS) then: • add it as a new file to directory /etc/pki/ca-trust/source/ • run update-ca-trust extract and of course: man update-ca-trust
5.4 Locations of certificates
"/etc/ssl/certs/ca-certificates.crt", | // Debi*an/Ubuntu/Gentoo etc. |
"/etc/pki/tls/certs/ca-bundle.crt", | // Fedora/RHEL 6 |
"/etc/ssl/ca-bundle.pem", | // OpenSUSE |
"/etc/pki/tls/cacert.pem", | // OpenELEC |
"etc/pki/ca-trust/extracted/pem | // CentOS/RHEL 7 |
tls-ca-bundle.pem" | |
"/etc/ssl/cert.pem", | // Alpine Linux |
Also: | |
"/etc/ssl/certs", | // SLES10/SLES11, |
https://golang.org/issue/12139 | |
"/system/etc/security/cacerts", | // Android |
"/usr/local/share/certs", | // FreeBSD |
"/etc/pki/tls/certs", | // Fedora/RHEL |
"/etc/openssl/certs", | // NetBSD |
"/var/ssl/certs", | // AIX |
6 Fix for 443 hanging on elpa.org or melpa.org
From this link I found that I needed to add this line to my init.el:
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
After that, I had no issues upgrading my emacs packages.
I turns out that setq
is not the preferred way to set variables.
(custom-set-variables '(gnutls-algorithm-priority "normal:-vers-tls1.3"))
(custom-set-variables '(gnutls-algorithm-priority "normal:-vers-tls1.3"))