tabnine-nvim icon indicating copy to clipboard operation
tabnine-nvim copied to clipboard

Constant "attempt to concatenate a nil value error"

Open vendion opened this issue 2 years ago • 14 comments

With the latest version of tabnine-nvim I get the following error message whenever I open Neovim:

Error executing vim.schedule lua callback: ...ocal/share/nvim/lazy/tabnine-nvim/lua/tabnine/binary.lua:49: attempt to concatenate a nil value
stack traceback:
        ...ocal/share/nvim/lazy/tabnine-nvim/lua/tabnine/binary.lua:49: in function 'binary_path'
        ...ocal/share/nvim/lazy/tabnine-nvim/lua/tabnine/binary.lua:65: in function 'start'
        ...ocal/share/nvim/lazy/tabnine-nvim/lua/tabnine/binary.lua:114: in function 'request'
        ...ocal/share/nvim/lazy/tabnine-nvim/lua/tabnine/status.lua:19: in function 'cb'
        vim/_editor.lua:263: in function <vim/_editor.lua:262>

Worse is whenever I dismiss this error it comes back up a few seconds later.

vendion avatar Jun 16 '23 09:06 vendion

please try running

cd ~/.local/share/nvim/lazy/tabnine-nvim
./dl_binaries.sh

If that doesn't fix the problem, could you share more information about your machine?

aarondill avatar Jun 16 '23 16:06 aarondill

If you try this command, it should output what neovim thinks your system details are.

$ nvim --headless '+lua =vim.inspect(vim.loop.os_uname())' '+qa'

aarondill avatar Jun 16 '23 16:06 aarondill

Inspecting the code, it seems that the arch_and_platform function is the only thing on this line that could return a nil value. I wonder if @vendion is using an unsupported combo (like arm64 linux) or a unix distribution such as freebsd (also unsupported).

aarondill avatar Jun 17 '23 08:06 aarondill

Yes, in this case I'm running FreeBSD, but that doesn't justify spamming me with the above error to the point that neovim is unusable. Instead of constantly throwing this error, if the plugin detects the platform is unsupported then it should stop trying to load or error silently rather than having me hit <Enter> multiple times a second.

vendion avatar Jun 17 '23 09:06 vendion

Now to be fair, FreeBSD does has the ability to run Linux binaries, so it is possible the amd64 Linux binary could work (similar to using wine to run Windows programs on Unix-like OS) but that is a different matter.

My use case isn't that uncommon, as I share all my configs across all my machines via a VCS repo (https://gitlab.com/vendion/dotfiles) which includes FreeBSD machines (amd64) and Linux (amd64, aarch64).

vendion avatar Jun 17 '23 09:06 vendion

To be clear, I'm not saying this is intended behavior, I was simply hypothesizing about the cause of the issue

aarondill avatar Jun 18 '23 05:06 aarondill

I wonder if just returning an empty string would even cause any issues...

something like this:

if os_uname.sysname == "Linux" and os_uname.machine == "x86_64" then
   return "x86_64-unknown-linux-musl"
elseif 
   -- ...
else
   return ""
end

the binary would not be found, causing the uv.spawn to return nil, and I think there's enough checks to ensure that doesn't throw an error?

Though in the long term, detecting unsupported configurations is a much better idea.

aarondill avatar Jun 18 '23 05:06 aarondill

same problem

hryacosta avatar Feb 16 '24 12:02 hryacosta

we were trying to resolve this at #82, but it seemed to stagnate when @amirbilu got busy. i'd appreciate more eyes on that code, or else another (replacement) PR with whatever Amir has in mind

aarondill avatar Feb 16 '24 18:02 aarondill

I had this exact problem while on an ARM linux machine (asahi fedora to be precise).

The fix I made was more or less following the conversation thread here. I narrowed the nil value output down to the case statements in arch_and_platform(), which did not account for the aarch64 linux platform. This is the change I ended up making in binary.lua:

local function arch_and_platform()
	local os_uname = uv.os_uname()

	if os_uname.sysname == "Linux" and os_uname.machine == "x86_64" then
		return "x86_64-unknown-linux-musl"
	-- REDFLAME2112: Added this line to help support aarch64 linux...
	elseif os_uname.sysname == "Linux" and os_uname.machine == "aarch64" then 
		return "aarch64-unknown-linux-gnu"
	elseif os_uname.sysname == "Darwin" and os_uname.machine == "arm64" then
		return "aarch64-apple-darwin"
	elseif os_uname.sysname == "Darwin" then
		return "x86_64-apple-darwin"
	elseif os_uname.sysname == "Windows_NT" and os_uname.machine == "x86_64" then
		return "x86_64-pc-windows-gnu"
	elseif os_uname.sysname == "Windows_NT" then
		return "i686-pc-windows-gnu"
	end
end

:)

RedFlame2112 avatar Mar 08 '24 20:03 RedFlame2112

Tabnine now offers arm64 support.. is there anyone here who will be willing to test it?

amirbilu avatar Jun 25 '24 16:06 amirbilu

Yes, I would be interested in trying it.

vendion avatar Jun 25 '24 18:06 vendion

@vendion I'm unable to test it atm as I don't have an access to an arm machime, can you please test this? https://github.com/codota/tabnine-nvim/pull/179/files Please make sure to run dl_binaries.sh first.

Appreciate your feedback!

amirbilu avatar Jun 27 '24 18:06 amirbilu

Merging this for now.. let me know if you have any issue

amirbilu avatar Jul 01 '24 08:07 amirbilu