Emacs is a powerful, extensible editor, and historically, it has integrated deeply with mail and news reading functionalities. This means the Emacs binary itself is often compiled with support for these features, and the package manager might pull in mail-related recommendations or dependencies.
To install GUI Emacs on Ubuntu with the fewest dependencies possible, especially avoiding MTAs and mail utilities, you have a couple of primary approaches:
Using apt with --no-install-recommends (Recommended First Step)
Compiling Emacs from Source (Ultimate Control)
Let's break down each method.
Method 1: Using apt with --no-install-recommends (Most Common & Easiest)
Ubuntu's apt package manager by default installs "recommended" packages alongside the ones you explicitly ask for. Many packages list mail clients or related utilities as "recommends." By telling aptnot to install recommendations, you can significantly reduce the number of pulled dependencies.
The package you want for GUI Emacs is typically emacs-gtk (for GTK3 support, which is standard on modern Ubuntu).
emacs-gtk: This is the package that provides the GTK-based graphical Emacs.
--no-install-recommends: This crucial flag tells apt to only install the hard dependencies of emacs-gtk, and skip anything listed under "Recommends" or "Suggests" in the package metadata. This is typically how you avoid pulling in things like mutt, gnupg, or other utilities that Emacs can use but doesn't strictly need to run.
Check for mail utilities (Optional but Recommended):
After installation, you can verify if any mail-related packages were inadvertently pulled in.
If you see any of these, it's likely they were already installed or were a hard dependency of something else on your system. emacs-gtk itself does not typically have a hard dependency on an MTA or mail utilities.
Why this often works:
The core Emacs binary, even when compiled with mail support, usually relies on external programs (like sendmail or mail) to actually send/receive mail. The emacs-gtk package rarely has a hard dependency on these MTAs.
The mailutils package is a separate utility package that provides the mail command-line tool, which Emacs can use, but doesn't strictly depend on.
Method 2: Compiling Emacs from Source (Ultimate Control)
If you need absolute certainty that Emacs is built without any internal mail-related code (e.g., if you're trying to achieve a security posture where even the possibility of Emacs initiating mail connections is removed), or if the --no-install-recommends method still pulls something you don't want, compiling from source is the way to go.
This allows you to explicitly disable features during the configure step.
Steps:
Install Build Dependencies:
You'll need build-essential and development libraries for the features you do want (like GTK for the GUI, XPM for image support, etc.).
Absolute minimum dependencies: You control exactly what gets compiled in.
Emacs itself will not have mail features enabled.
You get the latest stable version.
Cons:
More complex setup.
Requires development tools and libraries.
No automatic updates; you'll have to manually recompile for new versions.
May take longer to set up initially.
Verification
After installation (especially with apt --no-install-recommends), you can test Emacs's mail capabilities.
Start Emacs.
Try M-x rmail or M-x mail.
If Emacs has limited or no mail utilities installed on the system, it will likely complain about missing commands (like mail, sendmail, etc.) or simply not load the mail client. This is the desired behavior for your goal.
Choose the method that best suits your comfort level and the strictness of your "fewest dependencies" requirement. For most users, apt install --no-install-recommends emacs-gtk will be sufficient and easiest.
--without-selinux: Disables SELinux support.
--without-rsvg: Disables SVG image support.
--without-json: Disables JSON parsing support.
--with-jpeg, --with-png, --with-tiff, --with-gif: Include common image format support for the GUI. Omit these if you want an even more minimal GUI Emacs that can't display images.
--prefix=/usr/local/emacs-minimal: Installs Emacs to a specific directory (e.g., /usr/local/emacs-minimal) instead of the default /usr/local. This helps keep it separate from system-installed software. You'd then run it via /usr/local/emacs-minimal/bin/emacs.
Important: After running ./configure, read the output carefully. It will list what features are enabled/disabled based on available libraries and your flags. Ensure Mail is listed as "no".
Compile and Install:
bash
make -j$(nproc) # Use all CPU cores for faster compilation
sudo make install
Run Emacs:
If you used --prefix=/usr/local/emacs-minimal: