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!
(If you want to install Discourse for production use, see our install guide)
Install Discourse Dependencies
Run this script in terminal, to setup Rails development environment:
bash <(curl -s https://raw.githubusercontent.com/techAPJ/install-rails/master/mac)
This script will install following new packages on your system:
- Git
- rbenv
- ruby-build
- Ruby (latest stable)
- Rails
- PostgreSQL
- Redis
- Bundler
- Yarn
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.
Now that we have installed Discourse dependencies, let’s move on to install Discourse itself.
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
Now that you have successfully installed gems, run these commands:
bundle exec rake db:create
bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate
Try running the specs:
bundle exec rake autospec
All the tests should pass.
Start rails server:
bundle exec rails server
You should now be able to connect with your Discourse app on http://localhost:3000 - try it out!
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 MailCatcher:
mailcatcher --http-ip 0.0.0.0
Happy hacking! And to get started with that, see Beginner’s Guide to Creating Discourse Plugins.