TabNine icon indicating copy to clipboard operation
TabNine copied to clipboard

TabNine terminates immediately on NixOS

Open matthew-piziak opened this issue 7 years ago • 13 comments

From https://github.com/TommyX12/company-tabnine/issues/5.

How is this supposed to work?

~/TabNine/1.0.7/x86_64-unknown-linux-gnu $ chmod +x TabNine
~/TabNine/1.0.7/x86_64-unknown-linux-gnu $ ./TabNine
~/TabNine/1.0.7/x86_64-unknown-linux-gnu $

OS info:

 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.87, NixOS, 18.03.133389.b551f89e256 (Impala)`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.0.4`
 - channels(matt): `"nixos-18.03.133236.8edf566ee40, unstable-19.03pre152634.218ce4de508"`
 - channels(root): `"nixos-18.03.133389.b551f89e256, unstable-19.03pre162390.86344b3a52b"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixpkgs`

matthew-piziak avatar Dec 11 '18 22:12 matthew-piziak

Sorry to hear about this issue. Do you have glibc 2.14?

zxqfl avatar Dec 14 '18 03:12 zxqfl

Hi! Here is my output of ldd --version.

ldd (GNU libc) 2.26
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

matthew-piziak avatar Dec 14 '18 03:12 matthew-piziak

I'm not sure what is causing this issue. Could you run TabNine with strace and send the output?

zxqfl avatar Dec 14 '18 08:12 zxqfl

Okay so I've tried the new version and now it's weirder.

[matt@mus:~/TabNine/1.0.10/x86_64-unknown-linux-gnu]$ ls
TabNine

[matt@mus:~/TabNine/1.0.10/x86_64-unknown-linux-gnu]$ ./TabNine 
bash: ./TabNine: No such file or directory

[matt@mus:~/TabNine/1.0.10/x86_64-unknown-linux-gnu]$ file TabNine 
TabNine: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=53feef4db0112aedd0eb2057b41a571c0e5472c0, stripped

This was the version installed by company-tabnine.

matthew-piziak avatar Dec 15 '18 06:12 matthew-piziak

The problem is nixos doesn't support running dynamically linked binaries (at least without patching them first). In particular, /lib64/ld-linux-x86-64.so.2 doesn't exist on nixos. (it is at another path under /nix/store)

acertain avatar Dec 16 '18 20:12 acertain

Hmmm. What's the best path here? Should we provide a way to install the TabNine binary from the nixpgks repository, and then extend company-tabnine to use an existing TabNine installation?

matthew-piziak avatar Dec 16 '18 20:12 matthew-piziak

I did patchelf --set-interpreter /nix/store/84h2zni7h805k0i1ys2bba3dsp1cqnhh-glibc-2.26-131/lib/ld-linux-x86-64.so.2 TabNine, which is hacky. Probably zxqfl should be distributing statically linked binaries.

acertain avatar Dec 16 '18 21:12 acertain

Ok, I will consider switching to musl (https://rust-lang-nursery.github.io/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html).

zxqfl avatar Dec 18 '18 07:12 zxqfl

That patchelf command did not work for me. I just got warning: working around a Linux kernel bug by creating a hole of 2117632 bytes in ‘TabNine’, and then the same behavior as before.

matthew-piziak avatar Jan 06 '19 15:01 matthew-piziak

Hi @zxqfl, any update here? I'm happy to help if you can get me started. It would be nice to get this packaged up in a statically linked binary.

matthew-piziak avatar Feb 03 '19 18:02 matthew-piziak

patchelf worked for me with existing glibc path (which, weirdly enough, was shown in ldd TabNine output anyway, suggesting that the binary should have worked). Before that, the error was no such file or directory: ./TabNine.

alinnow avatar Jun 27 '19 09:06 alinnow

Thank you @alanpearce that worked for me too!

symbiont-matthew-piziak avatar Jun 27 '19 18:06 symbiont-matthew-piziak

All future builds of TabNine will have a statically linked version at https://update.tabnine.com/${version}/x86_64-unknown-linux-musl/TabNine. For example, https://update.tabnine.com/2.0.2/x86_64-unknown-linux-musl/TabNine.

Note that the clients for each editor still need to be updated to make the target configurable, as they will run x86_64-unknown-linux-gnu (not statically linked) by default. For the time being, you can overwrite the TabNine binary in x86_64-unknown-linux-gnu with the statically linked binary. This will break automatic updates, but it should otherwise work ok.

zxqfl avatar Jul 19 '19 16:07 zxqfl