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

@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