Installing PeerTube on macOS

Part of the setup for developing a PeerTube plugin, is to install a PeerTube instance locally. The contributing and dependencies docs explain how to clone the PeerTube repository, install dependencies and prepare the database. These resources also offer some OS specific tips. In this article we expand on some issues we ran into during installation on macOS, which is one of the operating systems we used for development (the other ones being Ubuntu in VMware, Ubuntu on WSL2, Ubuntu and Fedora on bare metal).

While following the dependencies guide for installation on macOS, we ran into a unknown user: postgres error. We have made a suggestion to describe this error more clearly in the guide, which has since been updated.

The provided solution of using _postgres instead of postgres as user name, resolved the error. However, using the _postgres user also brought along a permission issue:

$ sudo -u _postgres createuser -U peertube
Password:
could not identify current directory: Permission denied
createuser: error: could not connect to database template1: FATAL:  role "peertube" does not exist

As our current set up is for local development only, we ended up bypassing this by running as our current user, which has the right permissions:

createuser -P peertube
createdb -O peertube peertube_dev

Lastly, while testing that postgress was working properly, the psql command line tool expected a database with the name equal to the current user:

$ psql
psql: error: FATAL:  database "myawesomeusername" does not exist

We fixed this by creating that database:

createdb myawesomeusername

With a local database set up, the remaining prerequisites can be followed.

Once all prerequisites are met, we are ready to spin up our local PeerTube instance’ client and server side:

npm run dev

We can keep this command running while we are developing our plugin, to see the updated functionality reflected in our browser.