Beginners Guide to Install Discourse on Windows 10 for Development

dev-install

(Vinoth Kannan) #1

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

This setup needs Windows 10 Anniversary Update. We’ll assume that you already installed Windows Subsystem for Linux (Ubuntu) on your Windows 10 system. Let’s begin!

Initially follow the steps from the topic Beginners Guide to Install Discourse on Ubuntu for Development until the step Clone Discourse.

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

Then go through the remaining steps.

Now your development environment is almost ready. The only problem is every time when you open Ubuntu on Windows you have to start PostgreSQL service & Redis server manually. Don’t worry we can have a work around 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

To launch web server use bundle exec puma instead of rails server.


How to install Discourse on windows
Help installing Discourse for Developer
Beginners Guide to 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
Restoring backup fails in Win10/Ubuntu development environment
Restoring backup fails in Win10/Ubuntu development environment
Discourse installation end to end on Windows Server 2016
Beginners Guide to Install Discourse on Ubuntu for Development
How to add a new language
Beginners Guide to Install Discourse on Ubuntu for Development
»vagrant up« hangs
(Subasa) #4

thanks you, very very helpful for me!


#5

Great stuff here.

Having just completed an installation using this guide, here are two important notes you need to take into account:

  1. These instructions install Postgres 9.5, not Postgres 10 (which is in the official Docker image). You will need to upgrade your Postgres installation to be fully compatible with a Docker installation (backing up & restoring, for instance, will NOT work unless you update).

  2. I would alter the start-discourse command thusly, to ensure Sidekiq processes queues:

    #!/bin/bash
    
     # to start PostgreSQL
     sudo service postgresql start
    
     # to start redis server
     redis-server --daemonize yes
    
     # start Sidekiq (daemonized) with proper config or queues will not be processed!
     bundle exec sidekiq -d -C ./config/sidekiq.yml

(Vinoth Kannan) #6

It should be updated in original Ubuntu guide. cc @techAPJ


(Lê Trần Đạt) #7

For people who get this error

PG::Error: ERROR:  new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)

Follow the answer here:


(Thang Nguyen) #8

I am trying to set up the environment on Windows 10 (with Ubuntu as like above). Anyone has Unicorn error while trying to start the server ? The Unicorn errors keep looping and looping.

I, [2018-09-25T22:46:25.156669 #20007]  INFO -- : Refreshing Gem list
Starting CSS change watcher
  SiteSetting Load (0.5ms)  SELECT  "site_settings".* FROM "site_settings" WHERE "site_settings"."name" = 'vapid_public_key_bytes' LIMIT 1
E, [2018-09-25T22:46:30.068875 #20007] ERROR -- : 0.0.0.0:3000 {:tcp_defer_accept=>1, :accept_filter=>"httpready", :backlog=>1024, :tcp_nopush=>nil, :tcp_nodelay=>true}: Protocol not available - setsockopt(2) (Errno::ENOPROTOOPT)
E, [2018-09-25T22:46:30.070322 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/lib/unicorn/socket_helper.rb:74:in `setsockopt'
E, [2018-09-25T22:46:30.070588 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/lib/unicorn/socket_helper.rb:74:in `set_tcp_sockopt'
E, [2018-09-25T22:46:30.070858 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/lib/unicorn/socket_helper.rb:93:in `set_server_sockopt'
E, [2018-09-25T22:46:30.071134 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/lib/unicorn/socket_helper.rb:148:in `bind_listen'
E, [2018-09-25T22:46:30.071253 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:241:in `listen'
E, [2018-09-25T22:46:30.071537 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:851:in `block in bind_new_listeners!'
E, [2018-09-25T22:46:30.071809 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:851:in `each'
E, [2018-09-25T22:46:30.072045 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:851:in `bind_new_listeners!'
E, [2018-09-25T22:46:30.072755 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:140:in `start'
E, [2018-09-25T22:46:30.073488 #20007] ERROR -- : /home/hongthang152/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.0/bin/unicorn:126:in `<top (required)>'
E, [2018-09-25T22:46:30.074071 #20007] ERROR -- : /home/hongthang152/discourse/bin/unicorn:48:in `load'
E, [2018-09-25T22:46:30.074857 #20007] ERROR -- : /home/hongthang152/discourse/bin/unicorn:48:in `<main>'
I, [2018-09-25T22:46:30.075617 #20007]  INFO -- : listening on addr=0.0.0.0:3000 fd=13

(Thang Nguyen) #9

Nevermind. Ruby unicorn server seems to be broken on WSL. For those who encountered the above problem, starts the server with Puma server instead.

Run this script
bundle exec puma