<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ubuntu on The Emacs Cat</title>
    <link>https://olddeuteronomy.github.io/tags/ubuntu/</link>
    <description>Recent content in Ubuntu on The Emacs Cat</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 13 Aug 2026 10:55:47 +0100</lastBuildDate>
    <atom:link href="https://olddeuteronomy.github.io/tags/ubuntu/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Emacs, Dired, and Ubuntu 26.04</title>
      <link>https://olddeuteronomy.github.io/post/emacs-dired-ubuntu26/</link>
      <pubDate>Thu, 13 Aug 2026 10:55:47 +0100</pubDate>
      <guid>https://olddeuteronomy.github.io/post/emacs-dired-ubuntu26/</guid>
      <description>&lt;p&gt;Just recently I upgraded one of my Dell laptops to the latest Ubuntu&#xA;26.04 LTS with a clean install. The installation process was smooth&#xA;and enjoyable.&lt;/p&gt;&#xA;&lt;p&gt;Ubuntu 26.04 ships with Emacs 30.2, which made me happy, so I&#xA;installed it immediately—more precisely, the &lt;em&gt;emacs-pgtk&lt;/em&gt;&#xA;Wayland-optimized package, since Wayland is the default windowing&#xA;system on Ubuntu 26.04.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-problem&#34;&gt;The Problem&lt;/h2&gt;&#xA;&lt;p&gt;I started Emacs and, after a short time, ran into a problem: Dired&#xA;(&lt;code&gt;C-x d&lt;/code&gt;) did not work properly. It displayed a strange mess of&#xA;unsorted, chaotic entries, as shown below. It was a big surprise.&lt;/p&gt;&#xA;&lt;figure&gt;&lt;a href=&#34;https://olddeuteronomy.github.io/img/dired-ls.png&#34;&gt;&lt;img src=&#34;https://olddeuteronomy.github.io/img/dired-ls.png&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;&#xA;      &lt;h4&gt;Click or tap to view the full-size picture.&lt;/h4&gt;&#xA;    &lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&lt;p&gt;I&amp;rsquo;ve been using the same &lt;code&gt;.emacs&lt;/code&gt; &lt;a href=&#34;https://olddeuteronomy.github.io/post/multiplatform-emacs-config/&#34;&gt;multi-platform config&lt;/a&gt;&#xA;file for Linux, macOS, and Windows for years and have never had any&#xA;problems with Dired on different platforms, let alone across versions&#xA;of the same OS.&lt;/p&gt;&#xA;&lt;p&gt;My Dired configuration is quite simple:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;;;; `DIRED&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(require &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;dired&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;;; Dired options for Windows and non-Windows (Linux, macOS) systems.&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;;; http://oremacs.com/2015/01/13/dired-options/&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(if (&lt;span style=&#34;color:#a6e22e&#34;&gt;string-equal&lt;/span&gt; system-type &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;windows-nt&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (setq dired-listing-switches &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/A:H /O:NG&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (setq dired-listing-switches &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;-laGgh1v --group-directories-first --time-style=long-iso&amp;#34;&lt;/span&gt;))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;;; `dired-subtree&amp;#39; (since 2022-10-18)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;;; https://xenodium.com/drill-down-emacs-dired-with-dired-subtree/&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(use-package dired-subtree&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  :ensure &lt;span style=&#34;color:#66d9ef&#34;&gt;t&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  :after dired&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  :config&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (bind-key &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;lt;tab&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;#&amp;#39;&lt;/span&gt;dired-subtree-toggle dired-mode-map)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (bind-key &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;lt;backtab&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;#&amp;#39;&lt;/span&gt;dired-subtree-cycle dired-mode-map))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;;; By default, Dired buffers will not update themselves&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;;; unless you explicitly tell them to.&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(setq dired-auto-revert-buffer &lt;span style=&#34;color:#66d9ef&#34;&gt;t&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;dired-listing-switches&lt;/code&gt; variable defines the switches passed to&#xA;&lt;code&gt;dir&lt;/code&gt; or &lt;code&gt;ls&lt;/code&gt; for Dired on Windows and Linux/macOS systems,&#xA;respectively. I&amp;rsquo;ve been using this configuration for years.&lt;/p&gt;&#xA;&lt;p&gt;On Ubuntu 24.04 everything looks fine. So, what&amp;rsquo;s wrong with Emacs 30.2?&lt;/p&gt;&#xA;&lt;p&gt;I decided to test the &lt;code&gt;ls&lt;/code&gt; switches in the console. Oops&amp;mdash;the same&#xA;result as in Dired under Emacs 30.2!&lt;/p&gt;&#xA;&lt;figure&gt;&lt;a href=&#34;https://olddeuteronomy.github.io/img/dired-ls-console.png&#34;&gt;&lt;img src=&#34;https://olddeuteronomy.github.io/img/dired-ls-console.png&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;&#xA;      &lt;h4&gt;Click or tap to view the full-size picture.&lt;/h4&gt;&#xA;    &lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&lt;p&gt;This means the problem is &lt;em&gt;not&lt;/em&gt; with the new version of Emacs. After a&#xA;short search, the answer was found.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-bug-in-ubuntu-2604&#34;&gt;The Bug in Ubuntu 26.04&lt;/h2&gt;&#xA;&lt;p&gt;It turns out the bug in Ubuntu 26.04 is real, documented, and already tracked in&#xA;Ubuntu&amp;rsquo;s &lt;em&gt;Rust-based&lt;/em&gt; coreutils for Ubuntu 26.04. The issue&#xA;specifically affects &lt;code&gt;ls&lt;/code&gt; when using &lt;code&gt;--group-directories-first&lt;/code&gt; and&#xA;is tied to missing locale collation support in the Rust rewrite.&lt;/p&gt;&#xA;&lt;h3 id=&#34;launchpad-bug-2154042--incorrect-alphabetical-sorting-with---group-directories-first&#34;&gt;Launchpad Bug 2154042 — Incorrect alphabetical sorting with &lt;code&gt;--group-directories-first&lt;/code&gt;&lt;/h3&gt;&#xA;&lt;p&gt;This is the main &lt;a href=&#34;https://lists.ubuntu.com/archives/foundations-bugs/2026-May/549080.html&#34;&gt;bug report&lt;/a&gt;&#xA;affecting Ubuntu 26.04 users after the Rust coreutils transition.&#xA;It explicitly states that:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;ls&lt;/code&gt; from the Rust-based &lt;em&gt;coreutils&lt;/em&gt; does not sort alphabetically when using &lt;code&gt;--group-directories-first&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The bug appears both when &lt;code&gt;LC_ALL&lt;/code&gt; is set and when it is unset.&lt;/li&gt;&#xA;&lt;li&gt;GNU &lt;code&gt;ls&lt;/code&gt; (&lt;code&gt;gnuls&lt;/code&gt;) sorts correctly; Rust &lt;code&gt;ls&lt;/code&gt; &lt;strong&gt;does not&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;Since Dired—and possibly other Emacs packages—uses &lt;code&gt;ls&lt;/code&gt; to list&#xA;directories and files, Dired &lt;strong&gt;will not&lt;/strong&gt; work properly on Ubuntu&#xA;26.04 regardless of the Emacs version.&lt;/p&gt;&#xA;&lt;h2 id=&#34;solution&#34;&gt;Solution&lt;/h2&gt;&#xA;&lt;p&gt;Luckily, the Ubuntu team has kept the old version of coreutils (GNU&#xA;coreutils), written in good old C. The GNU version of &lt;code&gt;ls&lt;/code&gt; is &lt;code&gt;gnuls&lt;/code&gt;&#xA;and is installed by default on Ubuntu 26.04. This means we can use&#xA;&lt;code&gt;gnuls&lt;/code&gt;—which works properly—for Dired instead of &lt;code&gt;ls&lt;/code&gt; when running&#xA;Ubuntu 26.04.&lt;/p&gt;&#xA;&lt;p&gt;To do this, we will use the &lt;code&gt;insert-directory-program&lt;/code&gt; variable, which&#xA;holds the absolute or relative name of the &lt;code&gt;ls&lt;/code&gt;-like program. This&#xA;variable is used by &lt;code&gt;insert-directory&lt;/code&gt; and &lt;code&gt;dired-insert-directory&lt;/code&gt;&#xA;(and therefore by Dired). Its default value on Linux and macOS is&#xA;&lt;code&gt;ls&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;First we need to determine the name and version of the OS. The custom&#xA;&lt;code&gt;ubuntu-version&lt;/code&gt; function helps with that:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(defun ubuntu-version ()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Return (MAJOR MINOR) as integers if running on Ubuntu, else nil.&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (when (and (&lt;span style=&#34;color:#a6e22e&#34;&gt;eq&lt;/span&gt; system-type &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;gnu/linux&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             (&lt;span style=&#34;color:#a6e22e&#34;&gt;file-readable-p&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/etc/os-release&amp;#34;&lt;/span&gt;))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (with-temp-buffer&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#a6e22e&#34;&gt;insert-file-contents&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/etc/os-release&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (let* ((os-release (&lt;span style=&#34;color:#a6e22e&#34;&gt;buffer-string&lt;/span&gt;))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             (is-ubuntu (string-match-p &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;^ID=ubuntu&amp;#34;&lt;/span&gt; os-release))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             (version-id (and is-ubuntu&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                              (when (&lt;span style=&#34;color:#a6e22e&#34;&gt;string-match&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;VERSION_ID=\&amp;#34;\\([0-9]+\\)\\.\\([0-9]+\\)\&amp;#34;&amp;#34;&lt;/span&gt; os-release)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                (&lt;span style=&#34;color:#a6e22e&#34;&gt;list&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;string-to-number&lt;/span&gt; (match-string &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; os-release))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                      (&lt;span style=&#34;color:#a6e22e&#34;&gt;string-to-number&lt;/span&gt; (match-string &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; os-release)))))))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        version-id))))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;On my machine &lt;code&gt;ubuntu-version&lt;/code&gt; returns &lt;code&gt;(26 4)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now we can replace &lt;code&gt;ls&lt;/code&gt; with &lt;code&gt;gnuls&lt;/code&gt; if we are on Ubuntu 26.x:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(when (&lt;span style=&#34;color:#a6e22e&#34;&gt;eq&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;car&lt;/span&gt; (ubuntu-version)) &lt;span style=&#34;color:#ae81ff&#34;&gt;26&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (setq insert-directory-program &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;gnuls&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#a6e22e&#34;&gt;message&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`ls&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; is replaced with &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`gnuls&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; on Ubuntu 26.x.&amp;#34;&lt;/span&gt;))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After that, Dired works as before.&lt;/p&gt;&#xA;&lt;figure&gt;&lt;a href=&#34;https://olddeuteronomy.github.io/img/dired-gnuls.png&#34;&gt;&lt;img src=&#34;https://olddeuteronomy.github.io/img/dired-gnuls.png&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;&#xA;      &lt;h4&gt;Click or tap to view the full-size picture.&lt;/h4&gt;&#xA;    &lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&lt;p&gt;Happy Emacsing on Ubuntu 26.04!&lt;/p&gt;&#xA;&lt;p&gt;&amp;ndash; The Emacs Cat.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
