Coder Social home page Coder Social logo

Error on startup about cmp-tabnine HOT 14 CLOSED

mayanksuman avatar mayanksuman commented on June 13, 2024
Error on startup

from cmp-tabnine.

Comments (14)

tzachar avatar tzachar commented on June 13, 2024

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

from cmp-tabnine.

mayanksuman avatar mayanksuman commented on June 13, 2024

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.

Screenshot from 2021-09-15 12-21-39

from cmp-tabnine.

tzachar avatar tzachar commented on June 13, 2024

Are you using WSL, or is this native windows?

from cmp-tabnine.

mayanksuman avatar mayanksuman commented on June 13, 2024

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

from cmp-tabnine.

tzachar avatar tzachar commented on June 13, 2024

Ok, can you do a find . in the binaries dir?

from cmp-tabnine.

mayanksuman avatar mayanksuman commented on June 13, 2024

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

from cmp-tabnine.

tzachar avatar tzachar commented on June 13, 2024

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

from cmp-tabnine.

mayanksuman avatar mayanksuman commented on June 13, 2024

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

from cmp-tabnine.

tzachar avatar tzachar commented on June 13, 2024

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.

from cmp-tabnine.

tzachar avatar tzachar commented on June 13, 2024

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

from cmp-tabnine.

mayanksuman avatar mayanksuman commented on June 13, 2024

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

from cmp-tabnine.

tzachar avatar tzachar commented on June 13, 2024

closing

from cmp-tabnine.

Act0r1 avatar Act0r1 commented on June 13, 2024

Are you using WSL, or is this native windows?

I'm using wsl and got this error, how I can fix that?

from cmp-tabnine.

tzachar avatar tzachar commented on June 13, 2024

idk, please provide more info in a new issue.

from cmp-tabnine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.