Search code examples
neovim

Neovim can't find node (among others)


I just tried setting up Neovim on my machine using kickstart.nvim; however, I ran into a problem. When using checkhealth, I noticed that node was not found despite it being present on my system.

I tried checking inside a Neovim terminal if it could locate node (and bash for a good result). These are the results:

Terminal:

jimmy@jimmy-Aspire-E5-575G:~$ which bash
/usr/bin/bash
jimmy@jimmy-Aspire-E5-575G:~$ which node
/usr/bin/node
jimmy@jimmy-Aspire-E5-575G:~$ node -v
v20.6.1
jimmy@jimmy-Aspire-E5-575G:~$ 

Neovim:

:!which bash
/usr/bin/bash

:!which node
which: no node in (/home/jimmy/.var/app/io.neovim.nvim/data/nvim/mason/bin:/app/bin:/usr/bin:/home/jimmy/.var/app/io.n
eovim.nvim/data/node/bin:/home/jimmy/.var/app/io.neovim.nvim/data/cargo/bin:/home/jimmy/.var/app/io.neovim.nvim/data/p
ython/bin:/home/jimmy/.var/app/io.neovim.nvim/data/gem/ruby/3.2.0/bin)

shell returned 1

As you can see node is certainly installed on my system and located in /usr/bin which is in the path. In Neovim, it even prints that it's looking for node in that directory but it still doesn't find it.

Just in case, I checked the PATH variable in both the terminal and Neovim.

Terminal:

jimmy@jimmy-Aspire-E5-575G:~$ echo $PATH | tr ':' '\n'
/home/jimmy/.cargo/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
/var/lib/flatpak/exports/bin

Neovim:

:!echo $PATH | tr ':' '\n'
/home/jimmy/.var/app/io.neovim.nvim/data/nvim/mason/bin
/app/bin
/usr/bin
/home/jimmy/.var/app/io.neovim.nvim/data/node/bin
/home/jimmy/.var/app/io.neovim.nvim/data/cargo/bin
/home/jimmy/.var/app/io.neovim.nvim/data/python/bin
/home/jimmy/.var/app/io.neovim.nvim/data/gem/ruby/3.2.0/bin

I find it quite strange that the path in Neovim differs from the terminal, yet the directory node is in is present in both. So, it should be visible from Neovim.

I tired searching for similar problems, but all the solutions I found basically said to check if node is installed on the system.

Update

After thinking a bit more about it I found it really strange that node is not present in /usr/bin when running Neovim, so I checked what is in that directory in both the terminal and Neovim and compare them. There seem to be quite a lot of differences that i can't really explain. Here is the terminal and Neovim /usr/bin content.


Solution

  • I found what was wrong in my case. Sharing in case someone is encountering the same issue.

    When running Neovim and inpecting the process with htop, I found that it was invoked with bwrap. After reading the man page for that, I figured that would be the reason some things on my system were not available. After a bit of reasoning I thought the only reason for this would be the package manager I used to install Neovim with, Flatpak. With A quick google I found that was indeed the case.

    So I just got the latest tar for Neovim, extracted that and sure enough everything is fine now.