Why micro is not recognized as text editor in Ubuntu 22.04?
There appears to be no post install script included by the package maintainer to do that in the micro
package:
$ apt source micro
Reading package lists... Done
NOTICE: 'micro' packaging is maintained in the 'Git' version control system at:
https://salsa.debian.org/go-team/packages/micro.git
Please use:
git clone https://salsa.debian.org/go-team/packages/micro.git
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 820 kB of source archives.
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/universe micro 2.0.9-1ubuntu0.22.04.2 (dsc) [2,664 B]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/universe micro 2.0.9-1ubuntu0.22.04.2 (tar) [812 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/universe micro 2.0.9-1ubuntu0.22.04.2 (diff) [5,528 B]
Fetched 820 kB in 2s (369 kB/s)
dpkg-source: info: extracting micro in micro-2.0.9
dpkg-source: info: unpacking micro_2.0.9.orig.tar.gz
dpkg-source: info: unpacking micro_2.0.9-1ubuntu0.22.04.2.debian.tar.xz
dpkg-source: info: using patch list from debian/patches/series
dpkg-source: info: applying 01-disable-commit-hash-and-date.patch
dpkg-source: info: applying use-original-fork.patch
$
$
$ find micro-2.0.9/ -name "*postinst" -print -exec cat {} \;
$
Compare that to e.g. the nano
package:
$ apt source nano
Reading package lists... Done
NOTICE: 'nano' packaging is maintained in the 'Git' version control system at:
https://salsa.debian.org/debian/nano.git
Please use:
git clone https://salsa.debian.org/debian/nano.git
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 1,567 kB of source archives.
Get:1 http://archive.ubuntu.com/ubuntu jammy/main nano 6.2-1 (dsc) [2,192 B]
Get:2 http://archive.ubuntu.com/ubuntu jammy/main nano 6.2-1 (tar) [1,532 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main nano 6.2-1 (asc) [833 B]
Get:4 http://archive.ubuntu.com/ubuntu jammy/main nano 6.2-1 (diff) [32.7 kB]
Fetched 1,567 kB in 2s (860 kB/s)
dpkg-source: info: extracting nano in nano-6.2
dpkg-source: info: unpacking nano_6.2.orig.tar.xz
dpkg-source: info: unpacking nano_6.2-1.debian.tar.xz
$
$
$ find nano-6.2/ -name "*postinst" -print -exec cat {} \;
nano-6.2/debian/nano.postinst
#!/bin/sh
set -e
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
update-alternatives --install /usr/bin/editor editor /bin/nano 40 \
--slave /usr/share/man/man1/editor.1.gz editor.1.gz \
/usr/share/man/man1/nano.1.gz
update-alternatives --install /usr/bin/pico pico /bin/nano 10 \
--slave /usr/share/man/man1/pico.1.gz pico.1.gz \
/usr/share/man/man1/nano.1.gz
fi
#DEBHELPER#
nano-6.2/debian/nano-tiny.postinst
#!/bin/sh
set -e
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
update-alternatives --install /usr/bin/editor editor /bin/nano-tiny 0 \
--slave /usr/share/man/man1/editor.1.gz editor.1.gz \
/usr/share/man/man1/nano-tiny.1.gz
fi
#DEBHELPER#
$
How to fix this?
Set the environment variable momentarily like so:
sudo EDITOR=micro visudo
Or add the editor to the Ubuntu alternatives system following the format:
update-alternatives --install <link> <name> <path> <priority>
like so:
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/micro 40
so that you can later select it via:
sudo update-alternatives --config editor
For additional related informative explanation see also:
Difference between "select-editor" and "update-alternatives --config editor"