HOWTO Set up a development environment using vagrant (Ubuntu guide)

(Tarek Loubani) #1

After having setup several systems with a discourse development environment using Vagrant, I thought I would write a quick guide here, which I really should submit as a README. This setup was tested on a virgin installation of 16.04, and uses Eclipse with Aptana Studio 3.

  1. Install requirements
    sudo apt install vagrant virtualbox virtualbox-dkms git
  1. Get Discourse source
    mkdir ~/workspace
    cd ~/workspace
    git clone
    # git clone # If you prefer HTTPS

  2. Start machine
    cd discourse
    vagrant up

  3. Enter VM
    vagrant ssh

  4. Go to Relevant directory
    cd /vagrant

  5. Finish setup of environment

bundle install
bundle exec rake db:create db:migrate db:test:prepare
  1. Create an admin account
cd /vagrant
rake admin:create
  1. Start Server. NOTE: You will need to execute all three of these commands every time!
    cd ~/
    mailcatcher --ip
    cd /vagrant
    bundle exec rails s -b
    bundle exec sidekiq -l log/sidekiq.log -q critical -q default -q low
  • Note: If you make changes in your code, please Ctrl-C both the rails server and sidekiq.
  • Note: You’ll need two consoles to run both sidekiq and the rails server.
  1. Point your browser to: - Discourse instance - Sidekiq queues - mailcatcher

  2. Optional Install Eclipse, egit and Aptana

Installing problem - bundle install
I want to build a debug version of discourse
Installing locally through vagrant
Vagrant: eviltrout user not found
Issue with vagrant version following the dev guide
Vagrant environment randomly hangs VirtualBox VM
Rake aborted message is showing when installing vagrant development
(cpradio) #2

Should we update this screen definition? So that starting all three items becomes as simple as screen -m -c vagrant.screen

(Joshua Rosenfeld) #3

Small issue I ran into: mailcatcher couldn’t be started from /vagrant, needed to return to home directory in order to run it.

(Tarek Loubani) #4

I updated the instructions.

(Tarek Loubani) #5

Would you believe that’s the first I see this… I don’t have enough experience with screen to comment, so obviously change if necessary. I did notice that sidekiq without -q default -q low -q critical does not execute all queues for some reason.

(Joshua Rosenfeld) #6

One more minor issue: these instructions leave you without any accounts, and thus no Admin accounts either. While the instance provides a link to creating an Admin account, should it be included here?

(Tarek Loubani) #7

Thank you. I added it as step #7.

(cpradio) #8

We can continue to massage it as issues arise, but I think this would be a good start. Might be able to even call this automatically via vagrant up? Not sure if that is a good idea or not.

(Joshua Rosenfeld) #9

Looks like #8 formatting was affected…

(Tarek Loubani) #10

OK, fixed it. Thank you.

(cpradio) #11

Okay, so after running vagrant ssh you can now run screen -m -c /vagrant/docs/vagrant.screen to start up rails s, rails c, sideqik, mailcatcher, and a bash terminal

You can then use CTRL + a, " to cycle through the various terminals.

(Anton) #12

So, at the end, do you edit code right in the ~/workspace/discourse and get your running instance updated automatically instantly?

(Tarek Loubani) #13

More or less…

You have to restart the sidekiq and rails s servers each time you make a change to the code.

(Tobias Eigen) #14

Hi Tarek - thanks for sharing this howto. I really appreciate it. I’ve tried following your instructions and noticed there are a few interim steps that are required. These become obvious as you move along but I thought I’d share them for the benefit of those who follow (including most likely myself… ;-)). I also found it helpful to review this discourse blog post about discourse as your first rails app while setting up virtualbox on my mac.

This is a good news, bad news post. Where I get stuck is on step 3. It hangs and eventually times out. I know this is a virtualbox/vagrant issue or even a hardware issue, but I’d be grateful for any advice. Here’s as far as I have come -

I followed these instructions found on stack overflow to add some lines to Vagrantinfo file, to turn on the gui so I can see what’s causing the holdup:

config.vm.provider :virtualbox do |vb|
  vb.gui = true

This is what I found:

I am puzzled because I have a newish 2015 macbook pro with retina display, and am fairly certain it supports hardware acceleration. Also not getting entirely why I’d need such a thing for a discourse dev box. Anyhoo, now off to try this on a different laptop…

(Tarek Loubani) #15

Hi Tobias,

Thank you for your comments. I’m not able to edit my first post for some reason (probably time), so unfortunately people will have to find your comments.

Regarding the virtualization, I know nothing of Apple devices, but usually that is turned ON in BIOS. Alternatively, you can turn off the setting (which would result in slower performance). Turn off the setting in System > Acceleration here:

I did a few web searches and see there is some discussion about how to enable in Macbooks. I won’t post them here so as not to misguide without testing, but please do post when you get it.

Thank you : )

(Erlend Sogge Heggen) #16

I’ve wikified your topic so that you may update the OP with any new information that has come along :slight_smile: