Page MenuHomePhabricator

Investigate why Joe is default editor on toollabs
Closed, ResolvedPublic

Description

Investigate and switch it back to the distro default.

Event Timeline

yuvipanda raised the priority of this task from to Needs Triage.
yuvipanda updated the task description. (Show Details)
yuvipanda added a project: Toolforge.
yuvipanda added subscribers: yuvipanda, Andrew, Petrb.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 27 2015, 4:07 PM
valhallasw triaged this task as Low priority.Jul 2 2015, 7:49 PM
valhallasw added a subscriber: valhallasw.
Restricted Application added a project: Cloud-Services. · View Herald TranscriptJul 2 2015, 7:49 PM

Might just be because of installing Joe? (T64236)

valhallasw moved this task from Triage to Backlog on the Toolforge board.Jul 2 2015, 7:54 PM
scfc closed this task as Declined.Jul 23 2015, 5:22 PM
scfc claimed this task.
scfc added a subscriber: scfc.

On tools-web-static-02 (as an example of a recently created instance) it isn't:

scfc@tools-web-static-02:~$ sudo update-alternatives --config editor
There are 5 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /bin/nano            40        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
  3            /usr/bin/emacs23     0         manual mode
  4            /usr/bin/vim.basic   30        manual mode
  5            /usr/bin/vim.tiny    10        manual mode

Press enter to keep the current choice[*], or type selection number: 
scfc@tools-web-static-02:~$

I assume @valhallasw is correct in that it might be related to the order in which packages are installed (or not). But resolving this would probably require determining which editor is to be recommended and which are not, while probably the first action of most users that encounter any "default" editor is to set their own customization:

scfc@tools-web-static-02:~$ sudo find /home -mindepth 2 -maxdepth 2 -type f -name .selected_editor | wc -l
89
scfc@tools-web-static-02:~$

(Yes, that's not all 759, but the "default editor" is probably only executed and thus the need for customization only arises when calling crontab -e and similar commands; others will just say vim file.txt.)

So before we spend too much time guessing which editor suits our users' needs best, let us just let them decide and point them to select-editor if necessary :-).

valhallasw reopened this task as Open.EditedMay 30 2016, 7:48 PM

Reopening this. For some reason, git starts joe (as valhallasw, on both tools-bastion-02 and -03) even though my

valhallasw@tools-bastion-03:~/src/pywikibot-core$ cat ~/.selected_editor
# Generated by /usr/bin/select-editor
SELECTED_EDITOR="/usr/bin/vim.tiny"

In any case, having Joe as fallback is not a great choice -- nano and mcedit are both much better, as they show which keys to use for a given command.

I have asked @Giftpflanze if they still use Joe, since they requested it. If they aren't I'm considering just uninstalling it...

Just typing editor in a shell prompt brings up joe, which on further investigation:

tom29739@tools-bastion-03:~$ type editor
editor is /usr/bin/editor
tom29739@tools-bastion-03:~$ file /usr/bin/editor
/usr/bin/editor: symbolic link to `/etc/alternatives/editor'
tom29739@tools-bastion-03:~$ file /etc/alternatives/editor
/etc/alternatives/editor: symbolic link to `/usr/bin/joe'

According to the git docs (https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration), "By default, Git uses whatever you’ve set as your default text editor ($VISUAL or $EDITOR) or else falls back to the vi editor to create and edit your commit and tag messages."

I set these in my .profile a few months ago in the hope that it would get rid of joe, and it works:

# Set default editor
export VISUAL=vim.basic
export EDITOR=vim.basic

git now launches vim (my preferred editor) when I commit. I also found this when looking through the select-editor man page: "SELECTED_EDITOR is overridden by the VISUAL and EDITOR environment variables."

Perhaps instead of using vi like the git docs suggests it does as a fallback, it's using the editor command or similar instead?

Perhaps instead of using vi like the git docs suggests it does as a fallback, it's using the editor command or similar instead?

Well-spotted. Debian passes DEFAULT_EDITOR=editor in the build process, which overrides the choice of vi as default editor.

Dzahn added a subscriber: Dzahn.EditedJul 5 2016, 5:23 PM
update-alternatives --config editor

example of the command above from my laptop:

There are 5 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/vim.gnome   60        auto mode
  1            /bin/nano            40        manual mode
  2            /usr/bin/vim.basic   30        manual mode
  3            /usr/bin/vim.gnome   60        manual mode
  4            /usr/bin/vim.nox     40        manual mode
  5            /usr/bin/vim.tiny    10        manual mode
tom29739@tools-bastion-03:~$ update-alternatives --config editor
There are 12 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/joe         70        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
  3            /usr/bin/emacs23     0         manual mode
  4            /usr/bin/emacs24     0         manual mode
  5            /usr/bin/jmacs       50        manual mode
  6            /usr/bin/joe         70        manual mode
  7            /usr/bin/jpico       50        manual mode
  8            /usr/bin/jstar       50        manual mode
  9            /usr/bin/mcedit      25        manual mode
  10           /usr/bin/rjoe        25        manual mode
  11           /usr/bin/vim.basic   30        manual mode
  12           /usr/bin/vim.tiny    10        manual mode

Press enter to keep the current choice[*], or type selection number:

Perhaps puppet installed joe last, and hence it got setup as the default editor.

Dzahn added a comment.EditedJul 5 2016, 5:32 PM

Yea, so anyone should be able to run that and pick the editor of their choice. Are we good then? Or do we want to reset it for everybody?

No, because they'd need to have root to run it?

And it's a systemwide setting - individual users can always set EDITOR in their homedirs. It's just that joe is a terrible default.

Although I've manually changed it on tools-login to point to nano.

Dzahn added a comment.Jul 5 2016, 5:50 PM

from the manpage of update-alternatives:

"many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice for an editor to invoke if the user has not specified a particular preference."

" Debian's alternatives system aims to solve this problem. A generic name in the filesystem is shared by all files providing inter‐changeable functionality. The alternatives system and the system administrator together determine which actual file is referenced by this generic name. For example, if the text editors ed(1) and nvi(1) are both installed on the system, the alternatives system will cause the generic name /usr/bin/editor to refer to /usr/bin/nvi by default. The system administrator can override this and
cause it to refer to /usr/bin/ed instead, and the alternatives system will not alter this setting until explicitly requested to do so."

bd808 added a subscriber: bd808.Jul 5 2016, 5:51 PM
alternatives::select { 'editor':
    path => '/bin/nano',
}

Change 297435 had a related patch set uploaded (by Merlijn van Deen):
toollabs: set nano as default editor

https://gerrit.wikimedia.org/r/297435

Change 297437 had a related patch set uploaded (by Yuvipanda):
tools: Explicitly set nano to be default editor

https://gerrit.wikimedia.org/r/297437

Change 297435 merged by Yuvipanda:
toollabs: set nano as default editor

https://gerrit.wikimedia.org/r/297435

Change 297437 abandoned by Yuvipanda:
tools: Explicitly set nano to be default editor

https://gerrit.wikimedia.org/r/297437

yuvipanda closed this task as Resolved.Jul 5 2016, 7:09 PM
yuvipanda reassigned this task from scfc to valhallasw.

The puppet patch's fixed it now! \o/