Closed mayanksuman closed 3 years ago
It looks like you do not have the TabNine binary installed.
I've added a proper error message in c3a168e.
Please verify your installation by running install.sh
I forgot to mention in the issue description. Actually, I have TabNine binary (which I checked in the file explorer). However, still this issue comes.
Screenshot of vim startup (after updating and running install.sh
). I have TabNine 3.6.8 binaries.
Are you using WSL, or is this native windows?
No, I am not using WSL. My setup is
OS: Debian GNU/Linux bookworm/sid x86_64 Kernel: 5.10.0-8-amd64 DE: GNOME 3.38.6 Shell: zsh 5.8 NVIM v0.5.0 LuaJIT 2.1.0-beta3
Ok, can you do a find .
in the binaries dir?
The result for find .
.
./3.6.8
./3.6.8/x86_64-unknown-linux-musl
./3.6.8/x86_64-unknown-linux-musl/TabNine
./3.6.8/x86_64-unknown-linux-musl/TabNine-deep-cloud
./3.6.8/x86_64-unknown-linux-musl/TabNine-deep-local
./3.6.8/x86_64-unknown-linux-musl/WD-TabNine
The result for tree
in the same directory.
.
└── 3.6.8
└── x86_64-unknown-linux-musl
├── TabNine
├── TabNine-deep-cloud
├── TabNine-deep-local
└── WD-TabNine
2 directories, 4 files
Can you try this patch, and show me the output?
diff --git a/lua/cmp_tabnine/source.lua b/lua/cmp_tabnine/source.lua
index 6f3cd80..733b1cf 100644
--- a/lua/cmp_tabnine/source.lua
+++ b/lua/cmp_tabnine/source.lua
@@ -25,14 +25,18 @@ local binaries_folder = fn.expand('<sfile>:p:h:h:h') .. '/binaries'
local function binary()
local versions_folders = fn.globpath(binaries_folder, '*', false, true)
local versions = {}
+ dump(versions_folders)
for _, path in ipairs(versions_folders) do
+ dump(path)
for version in string.gmatch(path, '/([0-9.]+)$') do
+ dump('version:', version)
if version then
table.insert(versions, {path=path, version=version})
end
end
end
table.sort(versions, function (a, b) return a.version < b.version end)
+ dump(versions)
local latest = versions[#versions]
if not latest then
vim.notify('cmp-tabnine: Cannot find installed TabNine. Please run install.sh')
The version_folder
in my case is empty. Got following dump
{}
{}
cmp-tabnine: Cannot find installed TabNine. Please run install.sh
{}
{}
cmp-tabnine: Cannot find installed TabNine. Please run install.sh
I then printed out binaries_folder
and I got "~/.dotfile/nvim/.config/binaries", which is wrong.
I guess issue is coming due to my choice of package manager. I use packer
for managing my package. packer
make packer_compiled.lua
that load, run and configure all plugins. Hence, the code fn.expand('<sfile>:p')
is giving the output as ~/.dotfile/nvim/.config/nvim/plugin/packer_compiled.lua
I am also using packer, and do not have this issue.
Can you try doing require('cmp_tabnine.config').setup()
before loading any cmp
code?
A different option would be to allow users to override the automatic detection of the binaries directory.
can you also try this?
diff --git a/lua/cmp_tabnine/source.lua b/lua/cmp_tabnine/source.lua
index 6f3cd80..98b69ab 100644
--- a/lua/cmp_tabnine/source.lua
+++ b/lua/cmp_tabnine/source.lua
@@ -21,9 +21,14 @@ end
-- do this once on init, otherwise on restart this dows not work
local binaries_folder = fn.expand('<sfile>:p:h:h:h') .. '/binaries'
+function script_path()
+ local str = debug.getinfo(2, "S").source:sub(2)
+ return str:match("(.*/)")
+end
+
-- locate the binary here, as expand is relative to the calling script name
local function binary()
- local versions_folders = fn.globpath(binaries_folder, '*', false, true)
+ local versions_folders = fn.globpath(script_path() .. '../../binaries', '*', false, true)
local versions = {}
for _, path in ipairs(versions_folders) do
for version in string.gmatch(path, '/([0-9.]+)$') do
I was able to solve the issue with following diff (also submitted as PR #4 ).
diff --git c/lua/cmp_tabnine/source.lua w/lua/cmp_tabnine/source.lua
index 6f3cd80e7e17..ad63509cb2bc 100644
--- c/lua/cmp_tabnine/source.lua
+++ w/lua/cmp_tabnine/source.lua
@@ -17,9 +17,27 @@ local function json_decode(data)
end
end
+local function get_path_separator()
+ if ((fn.has('win64') == 1) or (fn.has('win32') == 1)) then return '\\' end
+ return '/'
+end
+
+function script_path()
+ local str = debug.getinfo(2, "S").source:sub(2)
+ return str:match("(.*" .. get_path_separator() .. ")")
+end
+
+local function get_parent_dir(path)
+ local separator = get_path_separator()
+ local pattern = "^(.+)" .. separator
+ -- if path has separator at end, remove it
+ path = string.gsub(path, separator .. '*$', '')
+ local parent_dir = string.match(path, pattern) .. separator
+ return parent_dir
+end
-- do this once on init, otherwise on restart this dows not work
-local binaries_folder = fn.expand('<sfile>:p:h:h:h') .. '/binaries'
+local binaries_folder = get_parent_dir(get_parent_dir(script_path())) .. 'binaries'
-- locate the binary here, as expand is relative to the calling script name
local function binary()
closing
Are you using WSL, or is this native windows?
I'm using wsl and got this error, how I can fix that?
idk, please provide more info in a new issue.
My setup is similar to this gist. However, I am getting following error on startup.