tzachar / compe-tabnine

TabNine source for hrsh7th/nvim-compe
BSD 3-Clause "New" or "Revised" License
52 stars 3 forks source link

Binary folders are created in packer opt root directory not plugin dir on MacOS #17

Closed akinsho closed 3 years ago

akinsho commented 3 years ago

Hey 👋🏿 thanks for building this plugin, it's really helpful to have access to TabNine.

One issue I've noted only on my mac (I also run this on Linux but without issue) is that sometimes the binary version dirs such as 0.3.3 etc are created in ~/.local/nvim/site/pack/packer/opt/ rather than in the compe-tabnine directory specifically. I'm not sure if it's because some part of the install script uses something that doesn't work the same on macOS vs on linux since I've never seen that issue there. Do you have any idea what might cause this? can I provide any more information?

I use packer to install compe-tabnine as an opt plugin and have run = './install.sh'.

tzachar commented 3 years ago

I guess this has somehting to do with bash on macOS. If you look at the install script, it does the following:

cd $(dirname $0)

b4 anything else.

What happens if you do the following:

cd /tmp
~/.local/nvim/site/pack/packer/opt/compe-tabnine/install.sh

Does it work correctly?

akinsho commented 3 years ago

This is the output

➜ ~/.local/share/nvim/site/pack/packer/opt/compe-tabnine/install.sh
++ curl -sS https://update.tabnine.com/bundles/version
+ version=3.3.115
+ case $(uname -s) in
++ uname -s
+ platform=apple-darwin
++ uname -m
+ triple=x86_64-apple-darwin
++ dirname /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/install.sh
+ cd /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine
+ path=3.3.115/x86_64-apple-darwin
+ curl https://update.tabnine.com/bundles/3.3.115/x86_64-apple-darwin/TabNine.zip --create-dirs -o binaries/3.3.115/x86_64-apple-darwin/TabNine.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 17.7M  100 17.7M    0     0  42.8M      0 --:--:-- --:--:-- --:--:-- 42.7M
+ unzip -o binaries/3.3.115/x86_64-apple-darwin/TabNine.zip -d binaries/3.3.115/x86_64-apple-darwin
Archive:  binaries/3.3.115/x86_64-apple-darwin/TabNine.zip
  inflating: binaries/3.3.115/x86_64-apple-darwin/TabNine
  inflating: binaries/3.3.115/x86_64-apple-darwin/TabNine-deep-cloud
  inflating: binaries/3.3.115/x86_64-apple-darwin/TabNine-deep-local
  inflating: binaries/3.3.115/x86_64-apple-darwin/WD-TabNine
+ rm -rf binaries/3.3.115/x86_64-apple-darwin/TabNine.zip
+ chmod +x binaries/3.3.115/x86_64-apple-darwin/TabNine binaries/3.3.115/x86_64-apple-darwin/TabNine-deep-cloud binaries/3.3.115/x86_64-apple-darwin/TabNine-deep-local binaries/3.3.115/x86_64-apple-darwin/WD-TabNine
++ uname -s
+ target=binaries/TabNine_Darwin
+ rm binaries/TabNine_Darwin
+ ln -sf 3.3.115/x86_64-apple-darwin/TabNine binaries/TabNine_Darwin
/tmp                                                                                                                                                                                          14:50:04
➜ .ls
correct '.ls' to 'ls' [yes, no, edit, abort]? y
BEBA1C89-0AA7-4D53-A444-9C7D376E272F                                   lua_DMZBPJ
Developer                                                              lua_Dl1Mdq
com.apple.CoreSimulator.SimDevice.1D0ECC25-B9D0-438E-BA7F-82300454B2CB lua_M83zrk
com.apple.launchd.9ubEq76erl                                           lua_NwVbxi
com.apple.launchd.9xZ0YUPHNW                                           lua_PhrqbJ
com.apple.launchd.AQJRbWfeWe                                           lua_UiYhmK
com.apple.launchd.Djy42Gs0QF                                           lua_VoBlN3
com.apple.launchd.V6j5EEjo2X                                           lua_VvL7rx
com.apple.mobileassetd                                                 lua_YevHFU
com.google.Keystone                                                    lua_demp7f
fseventsd-uuid                                                         lua_jLB6BV
lua_4AuEp0                                                             lua_sxt4dx
lua_4l3Tk9                                                             lua_vVg9QM
lua_6nhfIY                                                             lua_zg430A
lua_8NgrJ3                                                             powerlog
lua_BeWlVZ                                                             tmux-501
/tmp                                                                                                                                                                                          14:50:14
➜

It doesn't appear to create a TabNine directory not sure if it should be something else but I don't see any relevant dirs created

tzachar commented 3 years ago

It looks like the install script is operating correctly. First, the script cds to /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine Later, it does the following: unzip -o binaries/3.3.115/x86_64-apple-darwin/TabNine.zip -d binaries/3.3.115/x86_64-apple-darwin, which should create the binaries directory inside the compe-tabnine dir.

This probably has something to do with packer on macOS. Can you try a different plugin manager on macOS and see if it works?

akinsho commented 3 years ago

@tzachar I'll give it a try might not be quick since I only use my mac for work so not as easy to swap out package managers at that time. If it is packer I'd be interested to know how or why since I contribute to that project already.

akinsho commented 3 years ago

Since this looks like it's related primarily to how packer handles running the install script I'm going to close this now, will revisit if it seems as though there's anything to be done here.

akinsho commented 3 years ago

@tzachar we've investigated this a bit on the packer side and I don't think it's coming from there. So I've looked into it a little more closely and I think it might be coming from TabNine somehow maybe an old tabnine process not sure basically then I run the install script it seems to be downloading version 3.4.2

compe-tabnine(main)                                                                                   17:24:36
➜ ./install.sh
++ curl -sS https://update.tabnine.com/bundles/version
+ version=3.4.2
+ case $(uname -s) in
++ uname -s
+ platform=apple-darwin
++ uname -m
+ triple=x86_64-apple-darwin
++ dirname ./install.sh
+ cd .
+ path=3.4.2/x86_64-apple-darwin
+ curl https://update.tabnine.com/bundles/3.4.2/x86_64-apple-darwin/TabNine.zip --create-dirs -o binaries/3.4.2/x86_64-apple-darwin/TabNine.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 20.5M  100 20.5M    0     0  20.0M      0  0:00:01  0:00:01 --:--:-- 20.0M
+ unzip -o binaries/3.4.2/x86_64-apple-darwin/TabNine.zip -d binaries/3.4.2/x86_64-apple-darwin
Archive:  binaries/3.4.2/x86_64-apple-darwin/TabNine.zip
  inflating: binaries/3.4.2/x86_64-apple-darwin/TabNine
  inflating: binaries/3.4.2/x86_64-apple-darwin/TabNine-deep-cloud
  inflating: binaries/3.4.2/x86_64-apple-darwin/TabNine-deep-local
  inflating: binaries/3.4.2/x86_64-apple-darwin/WD-TabNine
+ rm -rf binaries/3.4.2/x86_64-apple-darwin/TabNine.zip
+ chmod +x binaries/3.4.2/x86_64-apple-darwin/TabNine binaries/3.4.2/x86_64-apple-darwin/TabNine-deep-cloud binaries/3.4.2/x86_64-apple-darwin/TabNine-deep-local binaries/3.4.2/x86_64-apple-darwin/WD-TabNine
++ uname -s
+ target=binaries/TabNine_Darwin
+ rm binaries/TabNine_Darwin
+ ln -sf 3.4.2/x86_64-apple-darwin/TabNine binaries/TabNine_Darwin

But when I look into the files being created in packer's opt directory it's a version 0.0.1 and 3.4.2 version 0.1's directory contains only a binaries and bundle.lock file and 3.4.2 contains TabNine TabNine-deep-cloud TabNine-deep-local WD-TabNine bundle.lock When I delete these folder they are constantly recreated immediately. I think maybe by TabNine, I'm not sure if there is an orphaned tabnine process or something which is recreating them

akinsho commented 3 years ago

I'll try killing all TabNine process and then deleting the folders and seeing if they stay deleted, then re-add it and see if it recreates them again

tzachar commented 3 years ago

TabNine self updates, and downloads newer versions of the binary. This is not the issue. Can you try the following and see if it helps?

diff --git a/install.sh b/install.sh
index 6b36b7f..388575a 100755
--- a/install.sh
+++ b/install.sh
@@ -6,6 +6,14 @@ set -o errexit
 set -o pipefail
 set -x

+# get the absolute path where the script resides. we want to install the
+# binaries there
+ABSOLUTE_PATH="$(\cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
+DIRNAME=$(dirname $ABSOLUTE_PATH)
+
+echo $ABSOLUTE_PATH
+echo $DIRNAME
+
 version=${version:-$(curl -sS https://update.tabnine.com/bundles/version)}

 case $(uname -s) in
@@ -22,11 +30,13 @@ triple="$(uname -m)-$platform"
 cd $(dirname $0)
 path=$version/$triple

-curl https://update.tabnine.com/bundles/${path}/TabNine.zip --create-dirs -o binaries/${path}/TabNine.zip
-unzip -o binaries/${path}/TabNine.zip -d binaries/${path}
-rm -rf binaries/${path}/TabNine.zip
-chmod +x binaries/$path/*
+curl https://update.tabnine.com/bundles/${path}/TabNine.zip \
+ --create-dirs \
+ -o ${DIRNAME}/binaries/${path}/TabNine.zip
+unzip -o ${DIRNAME}/binaries/${path}/TabNine.zip -d ${DIRNAME}/binaries/${path}
+rm -rf ${DIRNAME}/binaries/${path}/TabNine.zip
+chmod +x ${DIRNAME}/binaries/${path}/*

-target="binaries/TabNine_$(uname -s)"
-rm $target || true # remove old link
-ln -sf $path/TabNine $target
+target=${DIRNAME}/"binaries/TabNine_$(uname -s)"
+rm ${target} || true # remove old link
+ln -sf ${DIRNAME}/binaries/${path}/TabNine $target
akinsho commented 3 years ago

@tzachar thanks will try it out and update you 👍🏾

akinsho commented 3 years ago

Completely forgot to feedback on this issue as well that I tried the patch thanks for providing it but was still seeing the same issue. For the time being I've just deactivated the plugin as I haven't/don't have much time to debug atm. As I mentioned in the other issue I'm happy to close this as well for now if you'd rather not have these hanging around otherwise will get back to this when I get a bit more time.

EDIT: from what I recall it really didn't seem to be happening specifically at install or rather I installed it and checked and the directories weren't there. It wasn't till later when I tried a PackerClean that I noticed them so I'm not sure when they were created, but just not directly post install.

tzachar commented 3 years ago

This makes no sense. Please attach the output of the install script.

akinsho commented 3 years ago
➜ ./install.sh
+++ dirname ./install.sh
++ cd .
++ pwd
++ basename ./install.sh
+ ABSOLUTE_PATH=/Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/install.sh
++ dirname /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/install.sh
+ DIRNAME=/Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine
+ echo /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/install.sh
/Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/install.sh
+ echo /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine
/Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine
++ curl -sS https://update.tabnine.com/bundles/version
+ version=3.4.13
+ case $(uname -s) in
++ uname -s
+ platform=apple-darwin
++ uname -m
+ triple=x86_64-apple-darwin
++ dirname ./install.sh
+ cd .
+ path=3.4.13/x86_64-apple-darwin
+ curl https://update.tabnine.com/bundles/3.4.13/x86_64-apple-darwin/TabNine.zip --create-dirs -o /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.0M  100 19.0M    0     0  25.6M      0 --:--:-- --:--:-- --:--:-- 25.6M
+ unzip -o /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine.zip -d /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin
Archive:  /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine.zip
  inflating: /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine
  inflating: /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine-deep-cloud
  inflating: /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine-deep-local
  inflating: /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/WD-TabNine
+ rm -rf /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine.zip
+ chmod +x /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine-deep-cloud /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine-deep-local /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/WD-TabNine
++ uname -s
+ target=/Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/TabNine_Darwin
+ rm /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/TabNine_Darwin
+ ln -sf /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/TabNine_Darwin

@tzachar here's the output. I appreciate what I'm describing sounds strange as to me it does seem to be quite strange. For example I have tabnine currently installed and don't see this issue, I then deleted and re-installed it and still don't see this issue.

One thing that did occur to me is that I believe packer runs the run command every time a plugin is updated. It could be that during the update process the cwd isn't what is expected. Although we recently changed how packer sets the working directory before executing a script.

https://github.com/wbthomason/packer.nvim/commit/a5a6f41f5994d5a900ca610cb12cdde3a1a04f39

tzachar commented 3 years ago

Look at the last line:

ln -sf /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/3.4.13/x86_64-apple-darwin/TabNine /Users/akinso/.local/share/nvim/site/pack/packer/opt/compe-tabnine/binaries/TabNine_Darwin

Everything is installed correctly.

akinsho commented 3 years ago

@tzachar I'm happy to close this for now I appreciate it's a strange one, I'll report back here if I ever figure out what was/maybe is going on.