Install dependencies for a binary (on Debian)
Sometimes you might try to use a binary executable and not have all of the needed shared libraries. For instance, when trying to run Puppeteer's bundled Chromium on a server.
node_modules/puppeteer/.local-chromium/linux-599821/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory
You can search for the missing libraries one by one, or save time by installing them all at once, as follows:
Make sure you have apt-file and it is up-to-date:
apt-get install -y apt-file
apt-file update
Use ldd
to list needed shared libaries, select those that are missing, search
for them with apt-file
, and then pass the list of packages to apt-get
install
.
BINARY=path/to/binary
apt-get install $(
ldd $BINARY |
awk '/not found/{print $1}' | sort -u |
xargs -r -n1 -P`nproc` apt-file search |
grep : | cut -f1 -d: | sort -u )