Kitty: Dev dependencies docker image for Ubuntu?

Created on 23 Nov 2017  路  7Comments  路  Source: kovidgoyal/kitty

I'd like to try out kitty - but am running into a problem with the dev dependencies. My system (KDE neon user) has harfbuzz at 1.4.6 while kitty requires 1.5.1+. While I'm not averse to building stuff on my own, it's hard to find even a ppa for harfbuzz > 1.5 for Xenial.

It might be helpful to have a docker image with kitty dev dependencies so that folks don't have to update system libs just to try out kitty.

Most helpful comment

Kind of a pain but managed to install on Xenial. Because this library is used for font rendering I was very cautious about replacing the one on my system.

Just clone harfbuzz into your Downloads folder and compile and make, but don't do "make install". Then, modify pkg config path and add include path for harfbuzz. (I also ran into a libpng warning: just comment out the two errored lines). Then, you must direct ld to load the new harfbuzz .so file only for kitty.

~/Downloads/kitty$ export PKG_CONFIG_PATH=/home/andy/Downloads/harfbuzz/src
~/Downloads/kitty$ export CPATH=:/home/andy/Downloads/harfbuzz/src
~/Downloads/kitty$ make
~/Downloads/kitty$ LD_PRELOAD=/home/andy/Downloads/harfbuzz/src/.libs/libharfbuzz.so python3 .

Not very elegant but it does what it needs to.

All 7 comments

Not something I want to spend time on, but contributions are welcome. Note that building harfbuzz is trivial, and it does not need to overwrite system libs, you can simply install it into a private area and use PKGCONFIG_PATH to have kitty use the private harfbuzz. The kitty .travis.yml does it in five lines of code on an ancient distro (Ubuntu Trusty, IIRC).

Kind of a pain but managed to install on Xenial. Because this library is used for font rendering I was very cautious about replacing the one on my system.

Just clone harfbuzz into your Downloads folder and compile and make, but don't do "make install". Then, modify pkg config path and add include path for harfbuzz. (I also ran into a libpng warning: just comment out the two errored lines). Then, you must direct ld to load the new harfbuzz .so file only for kitty.

~/Downloads/kitty$ export PKG_CONFIG_PATH=/home/andy/Downloads/harfbuzz/src
~/Downloads/kitty$ export CPATH=:/home/andy/Downloads/harfbuzz/src
~/Downloads/kitty$ make
~/Downloads/kitty$ LD_PRELOAD=/home/andy/Downloads/harfbuzz/src/.libs/libharfbuzz.so python3 .

Not very elegant but it does what it needs to.

Thanks @xtknight - that helps (a little). So I got the thing to compile inside a docker contianer but when I run it from the host (libharfbuzz.so copied over), I'm running into

LD_PRELOAD=libharfbuzz.so python3 .
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "./__main__.py", line 68, in <module>
    main()
  File "./__main__.py", line 61, in main
    from kitty.main import main
  File "./kitty/main.py", line 11, in <module>
    from .borders import load_borders_program
  File "./kitty/borders.py", line 8, in <module>
    from .fast_data_types import (
ImportError: ./kitty/fast_data_types.so: undefined symbol: hb_ft_font_changed

That error is because your system is loading the old harfbuzz library. LD_PRELOAD requires a full path to the .so file. It you can't find it, try updatedb and locate

Kitty wants libpng16 which I strongly recommend you do not install on Xenial from the repos.

Here's the build script I divised.

#!/bin/bash
# harfbuzz
git clone https://github.com/harfbuzz/harfbuzz.git
cd harfbuzz
./autogen.sh
make -j8 
cd ..

# libpng16
if ! [ -e libpng-1.6.34.tar.xz ]; then
  wget "https://downloads.sourceforge.net/project/libpng/libpng16/1.6.34/libpng-1.6.34.tar.xz"
fi
tar -xvf libpng-1.6.34.tar.xz
cd libpng-1.6.34
make clean
./configure
make -j8 
cd ..

# kitty
CPATH=:$PWD/libpng-1.6.34:$PWD/harfbuzz/src PKG_CONFIG_PATH=$PWD/harfbuzz/src:$PWD/libpng-1.6.34 LDFLAGS="-L$PWD/libpng-1.6.34/.libs -L$PWD/harfbuzz/.libs" make -j8

This is my ~/bin/kitty:

#!/bin/bash
echo "$@"
LD_PRELOAD=$HOME/kitty/libpng-1.6.34/.libs/libpng16.so:$HOME/kitty/harfbuzz/src/.libs/libharfbuzz.so python3 $HOME/kitty "$@"

This allows the command line parameters to get passed to the python script properly.

LD_PRELOAD gets inherited into the kitty terminal environment which you may not want. I added this to my .bashrc:

if [ $TERM = "xterm-kitty" ]; then
  unset LD_PRELOAD
fi

Lastly, kitty adds $HOME/kitty/kitty/launcher/kitty to PATH and it won't work if you unset LD_PRELOAD so I deleted $HOME/kitty/kitty/launcher/kitty and replaced it with an ln -s $HOME/bin/kitty

Doesn't the latest Ubuntu LTS come with a new enough harfbuzz/libpng for kitty? In any case, a nicer kitty launch script, adapted from the README is:

#!/usr/bin/env python3

import runpy, os
os.environ['LD_LIBRARY_PATH'] = '/path/to/dir/containining/libpng16.so:/path/to/dir/containining/libharfbuzz.so'
runpy.run_path('/path/to/kitty/dir', run_name='__main__')

This avoids preloading the libs, so you should not need to remove LD_PRELOAD in your bashrc.

You can also avoid LD_LIBRARY_PATH completely by building kitty as

LD_RUN_PATH="/path/to/dir/containining/libpng16.so:/path/to/dir/containining/libharfbuzz.so" make

see https://homepages.inf.ed.ac.uk/imurray2/compnotes/library_linking.txt

See #595 for a binary kitty build for linux with all dependencies

Was this page helpful?
0 / 5 - 0 ratings

Related issues

reed-jones picture reed-jones  路  4Comments

mihaicristiantanase picture mihaicristiantanase  路  3Comments

crocket picture crocket  路  4Comments

lazarcf picture lazarcf  路  4Comments

bewzaalex picture bewzaalex  路  3Comments