canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.32k stars 926 forks source link

Impossible to use vim.basic when editing #6755

Closed kyrofa closed 4 years ago

kyrofa commented 4 years ago

Required information

Issue description

I can't seem to get vim.basic to be used when LXD opens an editor. For example:

$ sudo update-alternatives --config editor
There are 4 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/vim.basic   30        manual mode
  4            /usr/bin/vim.tiny    15        manual mode

$ lxc config edit my-container

# While the above is running
$ ps ax | grep vim
24007 pts/1    S+     0:00 vim.tiny /tmp/lxd_editor_122921485.yaml
24065 pts/2    S+     0:00 grep --color=auto vim

Note how vim.tiny is being run, despite vim.basic being configured. Okay, another test:

$ EDITOR=nano lxc config edit my-container

# While the above is running
$ ps ax | grep nano
24609 pts/1    S+     0:00 nano /tmp/lxd_editor_771127262.yaml
24687 pts/2    S+     0:00 grep --color=auto nano

That works as expected. Maybe let's try using vim.basic like that:

$ EDITOR=vim.basic lxc config edit my-container

# While the above is running
$ ps ax | grep vim
25401 pts/1    S+     0:00 vim.tiny /tmp/lxd_editor_874518561.yaml
25405 pts/2    S+     0:00 grep --color=auto vim

Nope, that still doesn't work. I swear this used to work, did something break? Or is vim falling out of favor? :wink:

stgraber commented 4 years ago

That's normal. The LXD snap cannot call a text editor outside of the snap environment. The snap itself bundles both vim.tiny and nano, so those are the only two options which work, anything else gets you back to vim.tiny.

If you want something else, your best bet is to do:

(Closing as this is expected behavior and also doesn't relate to LXD itself bu the snap instead.)