alexmurray / emacs-snap

GNU Emacs in a snap
https://snapcraft.io/emacs
71 stars 13 forks source link

treesit-install-language-grammar failure in emacs 29 #61

Closed balbert3 closed 11 months ago

balbert3 commented 12 months ago

Running treesit-install-language-grammar gives the error:

⛔ Warning (treesit): Error encountered when installing language grammar: (treesit-error Command: /snap/emacs/2103/usr/bin/gcc-10 -fPIC -c -I. parser.c Error output: In file included from ./tree_sitter/parser.h:9,
                 from parser.c:1:
/snap/emacs/2103/usr/lib/gcc/x86_64-linux-gnu/10/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
    9 | # include_next <stdint.h>
      |                ^~~~~~~~~~
compilation terminated.
)

This is with

$ snap list emacs
Name   Version                   Rev   Tracking     Publisher    Notes
emacs  29.0.92-emacs-29-37ed3d1  2103  latest/beta  alexmurray✪  classic

on

$ snap version 
snap    2.59.5
snapd   2.59.5
series  16
debian  12
kernel  6.1.0-10-amd64
alexmurray commented 12 months ago

Thanks for reporting this issue - is there a particular grammar you are trying to install where you see this?

Can you provide any more details on how to reproduce it?

balbert3 commented 12 months ago

Thanks. This was an issue for every grammar I tried e.g. the python grammar (https://github.com/tree-sitter/tree-sitter-python).

I just now installed gcc using apt in the base system and the error no longer occurs. I'm not sure if this is the correct solution because it seems that the snap packages its own version of gcc that perhaps should be used instead. A different error occurs btw when using treesit-install-language-grammar if git is not provided by the base system, although git does not seem to be packaged by the snap, so perhaps this is the expected behavior.

alexmurray commented 12 months ago

In general the emacs snap needs to use it's own libc and gcc to compile tree-sitter modules since they get loaded by emacs and hence need to be compatible with the toolchain that emacs itself was compiled with.

However I don't think you should have to install gcc yourself as this defeats the purpose of shipping our own gcc with the snap - so I think perhaps there is some missing include path or somesuch that is needed here.

Regarding git, that seems a bit different - in general, I don't think most users would expect emacs to use it's own git client instead of the host installed one... so for now I think that may have to stay as a 'known' issue.

I'll see if I can reproduce the general issue reported here though and try and fix that - out of interest, what distro are you running this on?

balbert3 commented 12 months ago

Great thanks again. This is an issue on Debian 12 and I've also reproduced it on Ubuntu 23.04.

alexmurray commented 12 months ago

I have managed to reproduce this and have come up with a fix in https://github.com/alexmurray/emacs-snap/commit/2d069d911ecaf519e9e5fd87e94ac64afedeae4e and have tested this locally against Ubuntu 18.04, 22.04 and 23.04.

I have also triggered new builds of the snap containing this fix which should be available in the next few hours - if you could please refresh to this new version and let me know if it fixes this issue for you as well that would be great.

balbert3 commented 11 months ago

Yes your updated snap fixes the issue for me (tested on Debian 12).

alexmurray commented 11 months ago

Excellent thanks for letting me know. I'll close this issue then.