Why your Debian version matters when installing Emacs

Debian's package repositories freeze when a release becomes stable, which means the Emacs version you get from apt install emacs on an older Debian system can be years behind the current release. On Crostini (the Linux container on Chrome OS), you are usually running Debian Bullseye or Bookworm, and the Emacs in those repositories may lack features, performance improvements, or bug fixes you need.

The straightforward solution is to compile Emacs from source. This takes longer than installing a pre-built package, but it gives you control over the exact version and features you get. The process is the same whether you are on Bullseye, Bookworm, or another older Debian release.

Key Takeaways

  • Compiling Emacs from source on Debian requires build tools and development libraries that you install once and reuse for other projects.
  • Download the Emacs source code directly from the GNU Emacs repository or from ftp.gnu.org, not from your package manager.
  • The configure and make steps take 10 to 30 minutes depending on your system and which optional features you enable.
  • After installation, the new Emacs binary lives in /usr/local/bin and takes priority over any older version in /usr/bin.

Install the build tools and libraries Emacs needs

Before you download Emacs, install the packages that let you compile software on Debian. Open a terminal in Crostini and run:

sudo apt update && sudo apt install build-essential libncurses-dev texinfo

This installs the C compiler, make, and other core tools. The libncurses-dev package is required for Emacs to build its terminal interface. The texinfo package lets Emacs build its documentation.

If you want Emacs to support graphics (the X11 window system), also install:

sudo apt install libx11-dev libxpm-dev libpng-dev libjpeg-dev libgif-dev libtiff-dev libxft-dev

On Crostini, graphics support is optional because you are usually running Emacs in a terminal anyway. If you are unsure, install these packages now — they do not hurt, and you can always rebuild later if you need them.

Download the Emacs source code

Go to the GNU Emacs download page at ftp.gnu.org/gnu/emacs/ and look for the most recent stable release. As of early 2024, that is usually Emacs 29.x. Download the tarball (the .tar.gz file) using wget:

cd /tmp && wget https://ftp.gnu.org/gnu/emacs/emacs-29.1.tar.gz

Replace 29.1 with whatever the latest version is. After the download finishes, extract the archive:

tar -xzf emacs-29.1.tar.gz && cd emacs-29.1

You now have a directory containing the full source code. The configure script and Makefile are already there — you do not need to generate them.

Configure and compile Emacs

Inside the emacs-29.1 directory, run the configure script. For a basic terminal-only build on Crostini, use:

./configure --prefix=/usr/local --without-x

The --prefix=/usr/local flag tells the build system to install Emacs in /usr/local/bin instead of /usr/bin. This keeps your new version separate from any older Emacs that came with Debian, and it survives system updates. The --without-x flag skips graphics support, which speeds up the build and is not needed in Crostini.

If you installed the graphics libraries and want to use them, omit the --without-x flag:

./configure --prefix=/usr/local

The configure script will run for a minute or two and print a summary of what it found. Check that it says "Does Emacs use the X Window System? no" (if you used --without-x) or "yes" (if you did not). If configure fails, read the error message — it usually tells you which library is missing.

After configure finishes, compile the code:

make -j4

The -j4 flag tells make to use 4 parallel jobs, which speeds up compilation on multi-core systems. This step takes 10 to 30 minutes depending on your Chromebook's processor and whether you included graphics support. You will see a lot of text scroll past — this is normal.

Install the compiled Emacs

After make finishes, install the new Emacs:

sudo make install

This copies the Emacs binary, libraries, and documentation to /usr/local/bin, /usr/local/lib, and /usr/local/share. The sudo command is needed because /usr/local is owned by root.

Verify the installation worked:

emacs --version

You should see the new version number. If you see an older version instead, your shell is still finding the old Emacs in /usr/bin. Run:

which emacs

This tells you which emacs your shell is using. If it says /usr/bin/emacs, close your terminal and open a new one — the shell caches the location of commands, and a fresh terminal will pick up the new one in /usr/local/bin.

Troubleshooting common build failures

If configure fails with a message about a missing library, install the -dev package for that library and run configure again. For example, if it says "libncurses not found", run sudo apt install libncurses-dev and try again.

If make fails partway through, the most common cause is running out of disk space in /tmp. Crostini containers have limited storage, and a full Emacs build can use 500 MB or more. Check your available space with df -h. If /tmp is full, delete the emacs-29.1 directory and start over in a different location, such as your home directory.

If the build succeeds but emacs --version still shows the old version, make sure /usr/local/bin comes before /usr/bin in your PATH. Run echo $PATH to see the order. If /usr/bin is first, add this line to the end of your ~/.bashrc file:

export PATH="/usr/local/bin:$PATH"

Then run source ~/.bashrc to reload your shell configuration.

Keeping your compiled Emacs up to date

When a new version of Emacs is released, you can repeat this process to build and install it. The new version will overwrite the old one in /usr/local/bin. You do not need to uninstall the old version first.

If you want to keep multiple versions installed, use a different --prefix for each one. For example, compile Emacs 29 with --prefix=/usr/local/emacs-29 and Emacs 30 with --prefix=/usr/local/emacs-30. Then run them explicitly by their full path: /usr/local/emacs-29/bin/emacs or /usr/local/emacs-30/bin/emacs.

Frequently Asked Questions

Can I use the Emacs from the Debian repository instead of compiling?

Yes, but you will get an older version. Run apt install emacs to install whatever Debian has packaged. This is faster and simpler, but you lose the ability to choose your version or enable specific features. If you only need basic Emacs functionality, the repository version is fine.

Do I need to compile Emacs every time I update Debian?

No. Emacs compiled from source and installed in /usr/local survives Debian updates. Your compiled version stays in place and continues to work. You only need to rebuild if you want a newer version of Emacs itself.

What does the --prefix flag do?

It tells the build system where to install the finished Emacs. Using --prefix=/usr/local keeps your compiled version separate from system packages in /usr/bin, so updates to Debian do not overwrite it. It also ensures /usr/local/bin takes priority in your PATH.

Can I use Emacs in the Crostini terminal, or do I need a graphical window?

Emacs works perfectly in the Crostini terminal without any graphics support. Compile with --without-x to skip graphics libraries and speed up the build. If you later want to use Emacs in a graphical window, rebuild without that flag.

How much disk space does compiling Emacs use?

The source code is about 50 MB, and the build process creates another 400 to 500 MB of temporary files. The final installed Emacs is about 50 to 100 MB depending on features. Make sure you have at least 1 GB free in your Crostini container before starting.