Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant "attempt to concatenate a nil value error" #77

Open
vendion opened this issue Jun 16, 2023 · 13 comments · May be fixed by #82
Open

Constant "attempt to concatenate a nil value error" #77

vendion opened this issue Jun 16, 2023 · 13 comments · May be fixed by #82

Comments

@vendion
Copy link

vendion commented Jun 16, 2023

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.

@aarondill
Copy link
Contributor

aarondill commented Jun 16, 2023

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
Copy link
Contributor

aarondill commented Jun 16, 2023

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
Copy link
Contributor

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).

@vendion
Copy link
Author

vendion commented Jun 17, 2023

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
Copy link
Author

vendion commented Jun 17, 2023

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).

@aarondill
Copy link
Contributor

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

@aarondill
Copy link
Contributor

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 added a commit to aarondill/tabnine-nvim that referenced this issue Jun 18, 2023
This avoids constant nil errors (fixes codota#77), and quits early if the binary can't be found.
Notifications can easily be added in future commits if so desired to warn the user about what is wrong.
@aarondill aarondill linked a pull request Jun 18, 2023 that will close this issue
aarondill added a commit to aarondill/tabnine-nvim that referenced this issue Jun 19, 2023
This avoids constant nil errors (fixes codota#77), and quits early if the binary can't be found.
Notifications can easily be added in future commits if so desired to warn the user about what is wrong.
aarondill added a commit to aarondill/tabnine-nvim that referenced this issue Jun 19, 2023
This avoids constant nil errors (fixes codota#77), and quits early if the binary can't be found.
Notifications can easily be added in future commits if so desired to warn the user about what is wrong.
aarondill added a commit to aarondill/tabnine-nvim that referenced this issue Jun 23, 2023
This avoids constant nil errors (fixes codota#77), and quits early if the binary can't be found.
Notifications can easily be added in future commits if so desired to warn the user about what is wrong.
aarondill added a commit to aarondill/tabnine-nvim that referenced this issue Jan 12, 2024
This avoids constant nil errors (fixes codota#77), and quits early if the binary can't be found.
Notifications can easily be added in future commits if so desired to warn the user about what is wrong.
@hryacosta
Copy link

same problem

@aarondill
Copy link
Contributor

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

@RedFlame2112
Copy link

RedFlame2112 commented Mar 8, 2024

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

:)

@amirbilu
Copy link
Contributor

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

@vendion
Copy link
Author

vendion commented Jun 25, 2024

Yes, I would be interested in trying it.

@amirbilu
Copy link
Contributor

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants