LukeSmithxyz / LARBS

Luke's Auto-Rice Bootstrapping Scripts: Installation Scripts for My Arch Linux Meta-Distribution
GNU General Public License v3.0
2.03k stars 798 forks source link

Set default visudo editor #480

Closed aartoni closed 1 year ago

aartoni commented 1 year ago

The sudoers man page states that:

The sudoers file should always be edited by the visudo utility which locks the file and checks for syntax errors.

LARBS doesn't currently set an editor for visudo so it tries to invoke its default (vi, which isn't installed by LARBS), resulting in the following error:

$ sudo visudo
visudo: no editor found (editor path = /usr/bin/vi)
majamin commented 1 year ago

sudo EDITOR=nvim visudo is fine. Or, soft link nvim to /usr/bin/vi.

aartoni commented 1 year ago

@majamin linking nvim to /usr/bin/vi looks kinda janky, running sudo EDITOR=nvim visudo would be fine if visudo didn't have a default editor setting exactly for this use case. Since LARBS already sets a default editor I find it consequential to set a default visudo editor, I mean, why would I bother setting EDITOR=nvim each time I need to edit a sudoers file?

Please note that the EDITOR variable will still be honored even if we set a default editor, that allows the user to run whatever editor/command for idiosyncratic use.