reddit / emacs
Self-compiling Emacs: What about the recommended Debian packages?
publicvoit · 2022-06-01 14:29
Hi, I want to give DIY-Emacs a shot and compiled the binary on my Xubuntu LTS according to that:
git clone git://git.sv.gnu.org/emacs.git
sudo apt install build-essential libgtk-3-dev libgnutls28-dev libtiff5-dev libgif-dev libjpeg-dev libpng-dev libxpm-dev libncurses-dev texinfo
cd emacs
./autogen.sh
./configure --with-pgtk
make -j8
Before I do `sudo make install` I need to get rid of the Debian packages that get replaced.
`sudo dpkg --get-selections| grep -i emacs` returns:
emacs
emacs-bin-common
emacs-common
emacs-el
emacs-gtk
emacsen-common
The first one is obvious: I need to do `sudo apt remove emacs` before the install commmand of my own version. But what about the rest? They also come with further dependencies such as `libgit2-28 libhttp-parser2.9 libm17n-0 libotf0 m17n-db` and even more on a different machine.
What packages can be removed and what should (may) I keep?
Is the self-compiled Emacs 100 percent self-contained so that I never need any additional library or package from my GNU/Linux distribution?
Thanks!
*Ceterum autem censeo* [*don't contribute anything relevant in web forums like Reddit only*](https://karl-voit.at/2020/10/23/avoid-web-forums)
**EDIT 2022-06-05**: Thanks for the tips here! They're part of my knowledge base now for future reference. I had to **switch back to Emacs 26** from my distro because too many things did not work with self-compiled Emacs any more (most important: my keyboard binding prefix "C-c C-," from my config) and I don't want to invest too much time fixing all those issues in order to be able to work again.
[deleted] · 2022-06-01 15:26
[deleted]
ForkInBrain · 2022-06-01 15:37
My advice: don't build Emacs and install it over Debian packages. Use the `--prefix` arg to configure to put it somewhere else, like a `~/bin` directory or under `/usr/local`. Personally, I just leave it in the build directory and run it from there! :-) I control which Emacs I run by editing my `PATH`.
While `apt-get build-dep emacs-gtk` will pull in the necessary build time dependencis, I don't think it will get you libgccjit, so the nativecomp feature won't work. If you want that, you'll need a libgccjit-dev package too.
If you do want to build a custom "system Emacs" and install it in a Debian-derived distro, there is a project somewhere on Github that lets you do this. The result is fully integrated with the Debian Emacs lisp package system, etc. I think this is more trouble than it is worth.
big_lentil · 2022-06-01 17:40
In theory removing the emacs package and then running apt-get autoremove should remove any unnecessary packages.
Maybe you could check apt logs to determine what else got installed when you installed emacs.
>Is the self-compiled Emacs 100 percent self-contained so that I never need any additional library or package from my GNU/Linux distribution?
No you need a bunch of libsomethings depending on your configuration. But AFAIK if you remove anything essential the dynamic linker will throw an error when you run emacs instead of going off into undefined behavior land so it's not too scary of an issue.
publicvoit · 2022-06-01 20:53
If I'd follow your advice to put it in a separate path, I presume I will get certain issues such as external tools calling emacs or emacsclient using the wrong binary. Furthermore, why would I want to keep more than one Emacs binary?
Is there a web page where I can learn what libraries I need from my distro for running GNU Emacs?
publicvoit · 2022-06-01 20:54
So do I understand you correctly that none of the listed packages from my original post are necessary? Because my DIY-binary doesn't introduce any dependency into my Debian-based system and therefore, all those packages get removed when "emacs" is uninstalled, I guess ...
ForkInBrain · 2022-06-01 21:24
> If I'd follow your advice to put it in a separate path, I presume I will get certain issues such as external tools calling emacs or emacsclient using the wrong binary.
Yes, this problem is a possibility. In my experience this is not a big deal. Most tools respect environment variables like EDITOR and PATH.
> Furthermore, why would I want to keep more than one Emacs binary?
I tend to keep the system provided Emacs around so I can run it and make sure my Emacs configuration works with it, but this is optional. One possible benefit of doing this is that extra programs and libraries that Emacs uses will be on your system. Your question makes me realize that I may have been benefiting from this for years. :-)
I see you're asking how to uninstall the Debian/Ubuntu Emacs. You can safely `apt remove` all of the `emacs-*` packages you listed in your original post. After that, `apt autoremove` will then remove any other packages that are installed just to support the system Emacs. It will print what is about to be removed, so you can stop it if something looks useful.
Emacs is fairly self contained but does rely on a lot of libraries (e.g. for image processing) and external programs (most of which are not necessary for basic editing but instead used by various Emacs packages that add extra functionality like spell checking, encryption, etc.).
> Is there a web page where I can learn what libraries I need from my distro for running GNU Emacs?
Not that I know of. That's why I do `apt-get build-dep emacs-gtk`, which installs development packages for what is needed to build Emacs. At build time the Emacs `./configure` script prints out what libraries it has found and tells you what it will be using for your particular build.
big_lentil · 2022-06-01 21:31
I just checked and I don't have any of the emacs* packages you listed above except emacsen-common
I tried to remove emacsen-common too but looks like that'd break my system for whatever reason, I'm not sure what's up with that. Doesn't seem like something that'd happen on a fresh install but IDK.
arthurno1 · 2022-06-02 01:30
You can just run Emacs directly from the source folder, don't need to even bother to make install.
> But what about the rest? They also come with further dependencies such as
Leave them alone, depending on your build options, your custom build Emacs will probably need some or all of those libraries too.
Phil-Hudson · 2022-06-03 13:40
No, don't delete the Debian packages. Follow @ForkInBrain 's advice about `--prefix` and then use the `update-alternatives` command to tell Ubuntu to use your new, distinct binaries. Here are the scripts I use: https://gitlab.com/-/snippets/2342491
nakkaya · 2022-06-03 21:29
See my docker image \[1\]. It contains the list of packages required to build Emacs with native compilation on Ubuntu, Debian packages should be the same. Depending on how you want to build it running \`build-dep\` pulls more packages than you need.
​
\[1\] https://github.com/nakkaya/emacsd/blob/master/Dockerfile