Skip to content

Instantly share code, notes, and snippets.

@volcan01010
Last active March 8, 2023 17:31
Show Gist options
  • Save volcan01010/6fcf7ae1f4975474ba9aac27efe17b84 to your computer and use it in GitHub Desktop.
Save volcan01010/6fcf7ae1f4975474ba9aac27efe17b84 to your computer and use it in GitHub Desktop.
Install instructions for terminalizer on Ubuntu 18.04 and 20.04

Terminalizer is tool for recording terminal sessions and turning them into animated gifs. It's a way to demonstrate command line tools or share workflows. Unfortunately, there are a few hoops to jump through to install it on Ubuntu. The issues seem to be with where the global npm installer tries to put the files and the permissions that they have.

asciinema and asciicast2gif produce simpler output but are easier to install.

Here are the steps that worked for me:

Installation

Ubuntu 20.04

# Install npm (requires dependencies) - Ubuntu 20.04
sudo apt install npm node-gyp libnode-dev libnss3 librust-gdk-pixbuf-sys-dev \
  libgtk-3-0 libxss1 libasound2 libgbm1

# Install terminalizer globally with unsafe permissions
sudo npm install -g terminalizer --unsafe-perm=true

# Grant global write access to render directory
sudo chmod 777 /usr/local/lib/node_modules/terminalizer/render/

Ubuntu 18.04

# Install npm (requires dependencies)
sudo apt install npm node-gyp nodejs-dev libssl1.0-dev

# Install terminalizer globally
sudo npm install -g terminalizer

# Remove the electron that comes with terminalizer
sudo rm -rf /usr/local/lib/node_modules/terminalizer/node_modules/electron/

# Add electron globally - based on this SO answer https://stackoverflow.com/a/52033822/3508733
sudo npm install -g electron --unsafe-perm=true --allow-root

# By this point, I could record and play sessions, but got the error in this issue when I tried to render them.
# Symlink the hardcoded rendering path to where terminalizer is actually installed on Ubuntu
sudo mkdir -p /usr/lib/node_modules/
sudo ln -s /usr/local/lib/node_modules/terminalizer/ /usr/lib/node_modules/terminalizer

# Change permissions on working directories
sudo chown -R <user> /usr/lib/node_modules/terminalizer/render
sudo chmod 4775 /usr/local/lib/node_modules/electron/dist/chrome-sandbox 

References

Electron error messages

For reference, and for Google's sake, here are error messages that I got along the way. Installing Terminalizer without the unsafe-perm flag caused an error with Electron:

me@u2004:/tmp$ terminalizer
/usr/local/lib/node_modules/electron/index.js:14
    throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
    ^

Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
    at getElectronPath (/usr/local/lib/node_modules/electron/index.js:14:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/electron/index.js:18:18)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Proxy.DI.require (/usr/local/lib/node_modules/terminalizer/di.js:105:29)

Rendering error messages

This next message came when I tried to render a gif:

18.04

$ terminalizer render foobar
Error: 
  EACCES: permission denied, mkdir '/usr/local/lib/node_modules/terminalizer/render/frames'

20.04

Error: 
  Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/terminalizer/render/frames'

This is because the hard-coded path to the render directory belongs to root. Also, in 18.04, it isn't where Ubuntu installs terminalizer. faressoft/terminalizer#29

@rsalmei
Copy link

rsalmei commented Aug 22, 2020

Hey,
Using your exact steps in ubuntu 20.04, I got:

Error:
  Error: /usr/local/lib/node_modules/terminalizer/node_modules/electron/dist/electron: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

I obviously tried to sudo apt install libnss3, which even having worked, has led me to:

Error:
  Error: /usr/local/lib/node_modules/terminalizer/node_modules/electron/dist/electron: error while loading shared libraries: libgdk_pixbuf-2.0.so.0: cannot open shared object file: No such file or directory

Which I resolved with sudo apt install librust-gdk-pixbuf-sys-dev, but then led me to:

Error:
  Error: /usr/local/lib/node_modules/terminalizer/node_modules/electron/dist/electron: error while loading shared libraries: libgtk-3.so.0: cannot open shared object file: No such file or directory

And then I've given up. Are you sure you had a clean machine? I've just started this one on aws, and those instructions don't work.
Thanks anyway.

@volcan01010
Copy link
Author

It wasn't a clean machine, but I'd never done any Node work on it. It was a desktop, too, so perhaps that's why all the GTK libraries were already installed.

@volcan01010
Copy link
Author

I tried installing into a clean Ubuntu Docker container with the instructions. As @rsalmei points out, there are more dependency issues. I have updated the Gist with all the ones that I needed. The original container is very minimal, so there are hundreds of Mb of requirements. (Note that I still didn't end up with a working version as the install was done as root and I had issues with the Chrome sandbox).

@CaptainHandyman
Copy link

Ubuntu version: Ubuntu 20.04.2 LTS

Working fine for me 👍

@logbasex
Copy link

Oops. I got this error: innerError Error: Cannot find module '../build/Debug/pty.node'

@travisdowns
Copy link

I can record after following this but render fails with:

Error: 
  Error: [3793890:0929/170405.714840:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.

Though this is Ubuntu 22.10.

@citosid
Copy link

citosid commented Jan 4, 2023

@travisdowns did you figure out what the problem was?

@travisdowns
Copy link

@citosid - no, I gave up and used asciinema IIRC.

@tambourine-man
Copy link

Thanks volcan01010
It doesn't seem to render on headless machines, but it does record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment