How to add NVim to update-alternatives when using Snap under Ubuntu?
To add NVim to update-alternatives when using Snap under Ubuntu, we can do this by using two different methods. Below we have listed both these methods:
- Method 1: Using update-alternatives
- Method 2: Manual Symlink
So let’s see both these methods in detail.
Method 1: Using update-alternatives
In this method, we will be using the update-alternatives. Follow the below specified steps:
Step 1: Firstly, confirm the location of the Neovim binary installed via snap, typically located in the /snap/bin/ directory. Execute the below command to confirm the location.
which nvim
Step 2: Then, integrate Neovim into the alternatives system, setting a priority of 100 for the snap version. Use the below command to integrate.
sudo update-alternatives --install /usr/bin/nvim nvim /snap/bin/nvim 100
Step 3: Choose the alternative configuration for Neovim using update-alternatives. Select the number corresponding to the snap version.
sudo update-alternatives --config nvim
Step 4: Confirm the alternative configuration for Neovim using update-alternatives –display nvim.
update-alternatives --display nvim
Step 5: Ensure that the version of Neovim displayed using nvim –version is the one installed via snap.
nvim --version
How to use update-alternatives
In the Ubuntu environment, adding NeoVim (nvim) to update-alternates while using Snap manager mainly involves the process of creating a symbolic link to the nvim executable in a directory listed in the system’s PATH. Snap packages are mainly isolated, so their binaries might not be automatically included in update-alternatives. To resolve this, we need to manually create a symbolic link from the nvim executable within the Snap package to the directory. In this article, we will see how we can add nvim to update-alternatives when using snap under Ubuntu.