Emacs CIDER removing old cider-compat namespace
The latest snapshot of CIDER includes some welcome tidy up of the code. One notable removal is cider-compat
which was added to support Emacs versions previous to 25. As most of the Emacs world is on version 27 (or 28 / 29) then there is no need to include cider-compat
any more.
However, some Emacs packages that haven't change in a while may still used cider-compat
, although the only one to date that has been found is helm-cider
. Unfortunately is causing Clojure file to fail to load when used with the latest CIDER snapshot.
When helm-cider is enabled, Emacs is unable to load Clojure files. The error reported is:
helm-cider-spec.el:27:1:Error: Cannot open load file: No such file or directory, cider-compat
Here are a few options to work around this issue
The maintainer of helm-cider has merged a fix already (Thank you Bozhidar) and a new package has been built by MELPA - https://melpa.org/#/helm-cider (see Build log for details)
Hack helm-cider code
There is only one line of code that is causing the issue, on line 27 of helm-cider-spec.el, so this can be deleted.
Restarting Emacs after this removal should resolve the issue.
The helm-cider package has not been updated since 2018 (it works very well, so no reason for an update until now). So hacking the helm-cider code should be a relatively quick and safe option
Fixing Helm-cider
An issue was raised on the helm-cider repository describing the issue.
It would seem that cider-compat namespace is not actually used by helm-cider-spec.el
namespace, so the fix would be to remove the (reqiure 'cider-compat)
line.
cider-compat
provides macros to define if-let*
and when-let*
if they are not already present. The helm-cider-spec namespace does not actually call either of these with the current code, so its superfluous anyway.
A pull request has been raised to delete the require. Hopefully the maintainer is able to push out a new version of the package.
Pinning a package in Spacemacs
Spacemacs uses packages from MELPA, where packages are generated daily from the latest commits of each package GitHub/GitLab repository.
Pin CIDER to an earlier version by adding the following recipe to dotspacemacs/additional-packages
(cider :location
(recipe :fetcher github
:repo "clojure-emacs/cider"
:commit "ae376429a8cf22b82a9e18ff844bdfbe5fc7ecc1"))
Delete the packages cider-*
, clojure-mode-*
and cider-eval-sexp-fu-*
from ~/.emacs.d/elpa/<emacs-version>/develop/
Reload the Spacemacs configuration, SPC f e R
, or restart Emacs, SPC q r
and the pinned version of Cider will be installed.
Pinning a package in Doom
All of Doom's packages are pinned by default. A pinned package is a package locked to a specific commit. So to pin CIDER to a version is of the form:
(package! cider :pin "ae376429a8")
Practicalli has only dabbled with Doom, so this hasn't been tested yet. Please let me know if this needs altering.
Summary
Using snapshot features does provide early access to improvements in packages and an opportunity to provide feedback to the maintainers. However, there is a small risk of having to manage an occasional issue such as this.
It is recommended that packages are only updated when you have spare capacity to resolve possible issues and do not have any time sensitive work to be done.
Most issues are fixed pretty quickly or at least have a work-around.
Thank you Practicalli