Install Discourse on Windows 10 for development

So you want to set up a development environment for Discourse on Windows 10 (or 11)? You can do it easily using Windows Subsystem for Linux feature. It is faster too :star_struck:.

This setup requires the WSL 2 installation. It is only available in Windows 10 builds 18917 or higher. We’ll assume that you already installed Windows Subsystem for Linux 2 (Ubuntu) on your Windows 10 system. WARNING: Install Ubuntu 18.04, and not 20.04 since some installations will fail on 20.04. For more information see June 30th, 2020 notes at the bottom of this post.

Let’s begin!

Installing Discourse

  1. Initially follow the steps from the topic Beginners Guide to Install Discourse on Ubuntu for Development until the step Clone Discourse.
  1. Before setting up the database you have to start PostgreSQL service & Redis server manually using following commands

    sudo service postgresql start
    redis-server --daemonize yes
    
  2. Then go through all the remaining steps of the Ubuntu guide.

Creating a Command to Start Discourse

Now your development environment is almost ready. The only problem is every time when you open Ubuntu on Windows you have to start the PostgreSQL service & Redis server manually. Don’t worry we can have a workaround for this by creating a custom command :wink:

cd ~

Create a new file using the command nano start-discourse and paste the content below then save and exit.

#!/bin/bash

# to start PostgreSQL
sudo service postgresql start

# to start Redis server
redis-server --daemonize yes

Now modify the CHMOD using below command

chmod +x start-discourse

And copy the file to your bin folder

sudo cp start-discourse /usr/bin/

It’s done. Now, whenever you open the Ubuntu bash just run the command below and start developing :+1:

start-discourse

Alternatively, if you are using Windows 10 enterprise, pro, or education edition then you can create a Linux virtual machine in hyper-v to set up the Discourse dev environment.

Notes About Windows Environment

As of June 30, 2020:
As of July 1, 2020

Last Reviewed by @AlexDev on 2022-06-16T02:00:00Z

44 Likes
How to install Discourse on windows
Help installing Discourse for Developer
Install Discourse on Ubuntu for Development
Database connection error when setting up Discourse development environment using Linux Bash Shell on Windows 10
Restoring backup fails in Win10/Ubuntu development environment
How can i install Discourse forum on my win 10 dedicated server OVH
How to Install Discourse on LocalHost in Windows?
Restoring backup fails in Win10/Ubuntu development environment
Dev Category sidebar
Install Discourse on Ubuntu for Development
Discourse installation end to end on Windows Server 2016
Install Discourse on Ubuntu for Development
Install Discourse on Ubuntu for Development
No connection to db issue
How to Install Discourse on LocalHost in Windows?
Install Discourse for development using Docker
Install Discourse on Ubuntu for Development
How to install on localhost
Help with setting up discourse An error occurred while installing xorcist (1.1.2), and Bundler cannot continue
WSL environment deadlocks
Problem with development on Windows with Docker and mounted volume
Please help, how do I install Discourse on macOS?
Install Discourse on Ubuntu for Development
Discourse standalone
Set up a local Discourse Development Environment?
Migrate a NodeBB forum with Redis to Discourse
Migrate a MyBB forum to Discourse
Migrate a NodeBB forum with MongoDB to Discourse
Migrate a Phorum forum to Discourse
Migrate a PunBB forum to Discourse
Migrate from another forum to Discourse
Unable to setup discourse in my windows 10
Discourse Development Contributor Guidelines
Problem in development Installation
Discourse eclipse in window
Install Discourse on Ubuntu for Development
Restoring backup fails in Win10/Ubuntu development environment
Topics which users cannot directly reply to, but can create a linked topic?
How to add a new language
How to Start Sidekiq When Using Puma
Discourse-webpack: A boilerplate for developing JS-heavy Discourse components
How can I directly edit Discourse database from a GUI?
Can't set up dev environment due to cppjieba_rb failing to install
Cloning and making our own Discourse community
How to Add Ngrok to Allowed Hosts
»vagrant up« hangs

I think there is a step missing. Before one runs bundle exec rake db:migrate one needs to run yarn to install all dependencies for node.js: yarn.

The db:migrate command appears to depend upon ~/discourse/app/assets/javascripts//node_modules/loader.js/dist/loader/loader.js which isn’t present until one has installed the dependencies.

Also, can I ask what the issues are with Ubuntu 20.04 that are making 18.04 the suggested install? I performed the install on 22.04 and it is running, although I did have to manually install libwebp6 for imagemagick to successfully install:

sudo dpkg -i libwebp6_0.6.1-2ubuntu0.20.04.1_amd64.deb

My instance seems to be running okay thus far but when I run bundle exec rake autospec I am seeing a lot of test failures.

2 Likes

Maybe related:

2 Likes