mastodon/SETUP.md

84 lines
2.7 KiB
Markdown
Raw Normal View History

2022-11-21 06:43:06 +00:00
# Setting up a dev environment
## Assumptions
You have a package manager, and your system is systemd-based.
## Prerequisites
2022-11-23 08:34:20 +00:00
### Nodejs
2022-11-21 06:43:06 +00:00
Install nodejs via your package manager. We used v19.1.0 for this setup.
2022-11-23 08:34:20 +00:00
### Ruby
2022-11-21 06:43:06 +00:00
Install ruby via your package manager of choice.
2022-11-23 08:34:20 +00:00
### Ruby Extras
2022-11-21 06:43:06 +00:00
Your distro may package `bundle` and `irb` in separate packages (Arch does). If they are, install them too.
On Arch these are `ruby-bundler` and `ruby-irb`.
2022-11-23 08:34:20 +00:00
### PostGreSQL
2022-11-21 06:43:06 +00:00
Install postgres via your package manager.
2022-11-23 08:34:20 +00:00
### Redis
2022-11-21 06:43:06 +00:00
Install redis via your package manager.
Enable and start the default `redis.service`
2022-11-21 10:06:35 +00:00
## Setting up the Environment
2022-11-21 06:43:06 +00:00
In the following instructions, replace USER with your *nix user name.
2022-11-21 08:31:46 +00:00
1. Add yourself to the postgres group with `sudo usermod -a -G postgres USER`. You'll need to log out and back in to
update your groups.
2. Navigate to the root of this repo.
2. Set up a local DB cluster with `pg_ctl -D data/postgres15 initdb -o '-U mastodon --auth-host=trust'`.
3. Add the line `unix_socket_directories='.'` to `data/postgres15/postgresql.conf`.
4. Run the DB with `pg_ctl -D data/postgres15 start`.
5. Run `bundle config set --local path 'vendor/bundle`. This will store the all the ruby gems locally so that we can
2022-11-21 10:27:58 +00:00
avoid interfering with system config.
6. Run `bundle install`.
7. Run `yarn install`.
8. Run `bundle exec rake db:setup`. If this fails, you can use `bundle exec rake db:reset` to forcibly regenerate it.
2022-11-21 06:43:06 +00:00
2022-11-21 10:06:35 +00:00
## Running Mastodon
2022-11-21 06:43:06 +00:00
2022-11-21 10:27:58 +00:00
1. To make our lives easier, we'll use `foreman` to run the site, so use `gem install foreman`.
2. Run `export RAILS_ENV=development` and `export NODE_ENV=development`.
2022-11-21 06:43:06 +00:00
a. Put these in your shell's .rc, or a script you can source if you want to skip this step in the future.
2022-11-21 10:27:58 +00:00
3. Run `bundle exec rake assets:precompile`.
2022-11-21 08:31:46 +00:00
a. If this explodes, complaining about `Hash`, you'll need to `export NODE_OPTIONS=--openssl-legacy-provider`. Same
2022-11-21 06:43:06 +00:00
deal as the above.
b. After doing this, you will need to `bundle exec rake assets:clobber` and then re-run
`bundle exec rake assets:precompile`.
2022-11-21 10:27:58 +00:00
4. Run `foreman start`
2022-11-21 06:43:06 +00:00
# Updates/Troubleshooting
## RubyVM/DebugInspector Issues
2022-11-21 08:31:46 +00:00
Still unable to fix. Circumvent by removing `better_errors` and `binding_of_caller` from Gemfile.
2022-11-21 06:43:06 +00:00
Happy to troubleshoot with someone better with Ruby than us >_<'/.
## Webpack Issues
If Webpack compalins about being unable to find some assets or locales:
Try:
1. `rm -rf node_modules`
2. `yarn install`
If this doesn't help, try:
2022-11-21 06:43:06 +00:00
2022-11-23 08:35:13 +00:00
1. `yarn add webpack`
2. `git restore package.json yarn.lock`
3. `yarn install`
2022-11-21 06:43:06 +00:00
Then re-run `foreman`. No. We have no idea why this worked.
If the above instructions don't work, please contact @Rin here, or @tammy@social.treehouse.systems.