eattherich.club

Manjastodon

How to run Mastodon on Manjaro for development. Adaptable to most *nix environments.

Adapted from the official mastodon docs.

ruby

Install rbenv(1) for managing ruby versions.

https://github.com/rbenv/rbenv#basic-github-checkout
git clone https://github.com/rbenv/rbenv.git ~/.config/rbenv
Optional: dynamic bash extension to speed up rbenv.
cd ~/.config/rbenv && src/configure && make -C src
Set RBENV_HOME to ~/.config/rbenv and configure PATH.
echo 'export RBENV_ROOT="$HOME/.config/rbenv"' >> ~/.bashrc
echo 'export PATH="$RBENV_ROOT:$PATH"' >> ~/.bashrc
rbenv requires the ruby-build plugin for installing ruby versions:
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Acquire ruby 2.7.2 and then bundler(1), foreman(1) and rails(1) via gem(1).

RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.7.2 --verbose
rbenv global 2.7.2
gem install bundler foreman rails --no-document
Note: the ruby install could take a fairly long time, using --verbose will bring clarity to this.

node

In similiar fashion to rbenv, use nvm(1) to manage node versions as well as install yarn(1).

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install 12
npm install --global yarn

postgresql and redis

Both can be installed with pamac(1) and then started via systemctl(1).

sudo pamac install postgresql redis
systemctl start redis
systemctl start postgresql
Before postgres will start you may need to initialize the database using the postgres user:
sudo su postgres -l
initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data/'
exit

local development

With the above tools installed and configured you are now prepared to work with the mastodon source code:

git clone https://github.com/tootsuite/mastodon.git ~/Projects/mastodon
Install bundler and yarn dependencies:
cd ~/Projects/mastodon
bundler install
yarn install
Setup the database using the rails script:
RALS_ENV="development" rails db:setup
If this fails be sure your UNIX user has the proper permissions:
sudo -u postgres createuser $USER --createdb

Finally use foreman to start the required services!

foreman start
Be sure the redis and postgresql services are running—else this will fail! Note that it may take awhile for webpack to compile everything, if you get asset errors be a little patient.

Your local development mastodon instance should be available at http://localhost:3000. The database is seeded with one admin user: admin@localhost:3000/mastodonadmin

Happy hacking!

last updated: 2021-05-29