Fix Erlang Mode Installation Error While Installing

I’m trying to install Elixir on my Ubuntu 14.04 system from the official Elixir website. When I run the command sudo apt-get install esl-erlang, I encounter this error, and I can’t figure out how to fix it.

Here’s what happens:

Error Code:

code$ sudo apt-get install esl-erlang
Reading package lists... Done
Building dependency tree
Reading state information... Done
esl-erlang is already the newest version.
The following packages were automatically installed and are no longer required:
libgconf2-4 python-requests-whl python-setuptools-whl python-six-whl
python-urllib3-whl python-wheel
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 406 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up erlang-mode (1:21.0.5-1) ...
ERROR: erlang-mode is broken - called emacs-package-install as a new-style add-on, but has no compat file.
Install emacsen-common for emacs23
emacsen-common: Handling install of emacsen flavor emacs23
Wrote /etc/emacs23/site-start.d/00debian-vars.elc
Wrote /usr/share/emacs23/site-lisp/debian-startup.elc
Install emacsen-common for emacs24
emacsen-common: Handling install of emacsen flavor emacs24
Wrote /etc/emacs24/site-start.d/00debian-vars.elc
Wrote /usr/share/emacs24/site-lisp/debian-startup.elc
Install erlang-mode for emacs
Install erlang-mode for emacs23
install/erlang: Handling install for emacsen flavor emacs23
Wrote /usr/share/emacs23/site-lisp/erlang/erlang-edoc.elc
Wrote /usr/share/emacs23/site-lisp/erlang/erlang-eunit.elc
Wrote /usr/share/emacs23/site-lisp/erlang/erlang-flymake.elc
Wrote /usr/share/emacs23/site-lisp/erlang/erlang-skels-old.elc
Wrote /usr/share/emacs23/site-lisp/erlang/erlang-skels.elc
Wrote /usr/share/emacs23/site-lisp/erlang/erlang-start.elc
Wrote /usr/share/emacs23/site-lisp/erlang/erlang.elc
Wrote /usr/share/emacs23/site-lisp/erlang/erlang_appwiz.elc

In toplevel form:
erldoc.el:64:1:Error: Cannot open load file: cl-lib
Wrote /usr/share/emacs23/site-lisp/erlang/path.elc
ERROR: install script from erlang-mode package failed
dpkg: error processing package erlang-mode (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
erlang-mode
E: Sub-process /usr/bin/dpkg returned an error code (1)

From what I can tell, the issue seems related to erlang-mode and some missing cl-lib dependency during the installation process for Emacs. The system is stuck, saying that something wasn’t fully installed or configured, and it returns an error every time I try to proceed.

Does anyone know how I can resolve this?

Explanation and Solution for Installing

When running the following command:

code$ sudo apt-get install esl-erlang

The package manager completes some installation steps but throws an error related to erlang-mode not being correctly configured. Here’s what happened in the output:

  1. Existing Installation Detected:
    • The message esl-erlang is already the newest version indicates that the Erlang package is already installed, so no new version will be installed.
  2. Unused Packages Warning:
    • The system notes that some previously installed packages are no longer required. You can remove them with: codesudo apt-get autoremove
  3. Partially Installed Packages:
    • The error indicates that one package (erlang-mode) was not fully configured. The error occurs during the setup of Emacs integrations for Erlang.
  4. Specific Error:
    • The system is trying to install erlang-mode for multiple Emacs versions (emacs23 and emacs24), but it encounters a missing dependency (cl-lib). This library is required but not found, causing the post-install script to fail.

Steps to Fix the Issue

Step 1: Install the cl-lib Package

The error message mentions that cl-lib is not available. You can install it manually with:

codesudo apt-get install elpa-cl-lib

If elpa-cl-lib is unavailable on Ubuntu 14.04, try:

codesudo apt-get install emacs23 emacs24 emacs24-common-non-dfsg

Clean up the Broken Package

You’ll need to clean up the broken package to proceed. Run:

codesudo dpkg --configure -a

This command reconfigures all partially installed packages.

Manually Remove erlang-mode if Issues Persist

If the problem persists with erlang-mode, remove it temporarily:

codesudo apt-get remove --purge erlang-mode

Then try installing Erlang again:

codesudo apt-get install esl-erlang

Final Thoughts

This error occurs due to a compatibility issue with the erlang-mode package for Emacs on older systems. If you don’t need the Emacs integration, removing erlang-mode is the quickest solution.

After performing the steps above, your Erlang installation should complete successfully. If you encounter further issues, updating your system packages or switching to a newer version of Ubuntu may help, as Ubuntu 14.04 is no longer fully supported.

Related blog posts