Install Discourse on macOS for development

:warning: This guide covers installation instructions for a macOS development environment, for production guides see: Install Discourse in production with the official, supported instructions

So you want to set up Discourse on macOS to hack on and develop with?

We’ll assume that you don’t have Ruby/Rails/Postgres/Redis installed on your Mac. Let’s begin :rocket: !

Install Discourse Dependencies

Run this script in your Terminal (or equivalent), to setup your machine for Discourse development:

bash <(curl -s https://raw.githubusercontent.com/discourse/install-rails/main/mac)

This script will install following new packages on your system:

In case you have any of this package pre-installed and don’t want to run entire script, see the script and pick the packages you don’t have currently installed. The script is fine-tuned for Discourse, and includes all the packages required for Discourse installation.

restart your terminal

Now that we have installed Discourse dependencies, let’s move on to install Discourse itself.

Restart your Terminal

Exit your shell and restarting it ensures that the paths to the installed packages are correctly picked up by the Terminal.

Clone Discourse

Clone the Discourse repository in ~/discourse folder:

git clone https://github.com/discourse/discourse.git ~/discourse

~ indicates home folder, so Discourse source code will be available in your home folder.

Bootstrap Discourse

Switch to your Discourse folder:

cd ~/discourse

Install the needed gems

bundle install

Install the JS dependencies

pnpm install

Next, run these commands to set up your local Discourse instance:

bundle exec rake db:create
bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate

Start rails + Ember servers, you have two options here.

Option 1: using two separate Terminal tabs/windows, run Rails and Ember CLI separately via

bundle exec rails server

and

bin/ember-cli

Option 2: using only one Terminal tab/window:

bin/ember-cli -u # will run the Unicorn server in the background

:tada: You should now be able to navigate to http://localhost:4200 to see your local Discourse installation. (Note that the first load can take up to a minute as the server is warmed up.)

You can also try running the specs:

bundle exec rake autospec

All (or almost all) the tests should pass.

Create New Admin

To create a new admin, run the following command:

RAILS_ENV=development bundle exec rake admin:create

Follow the prompts to create an admin account.

Configure Mail

Run MailHog:

mailhog

Congratulations! You are now the admin of your own Discourse installation!

Happy hacking! And to get started with that, see Beginner’s Guide to Creating Discourse Plugins.


This document is version controlled - suggest changes on github.

74 Likes