# Nice way to run a dev env

**URL:** https://meta.discourse.org/t/nice-way-to-run-a-dev-env/375233
**Category:** Extras
**Tags:** dev-install, development
**Created:** [July 22, 2025, 1:01pm UTC](https://meta.discourse.org/t/nice-way-to-run-a-dev-env/375233 "2025-07-22T13:01:36Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [July 22, 2025, 1:01pm UTC](https://meta.discourse.org/t/nice-way-to-run-a-dev-env/375233/1 "2025-07-22T13:01:36Z")

</div>

Hi everyone, just sharing a handy script I’ve put together that helps me run my Discourse dev instance.

It pulls all the latest changes, pulls the updates from installed plugins, and runs all the migrations, as well as installing the necessary gems and pnpm packages.

The downside to the script is that it also pulls the plugins bundled with core, which technically wouldn’t do anything since they would be updated with the first `git pull`. Oh well.

Note: [chatgpt.com](http://chatgpt.com) helped me write the `if` statement logic (my initial experiments failed).  
`~/rundiscourse.sh`:

```bash
#!/bin/bash

cd ~/discourse
git pull
cd plugins
PLUGIN_DIR=~/discourse/plugins

for folder in "$PLUGIN_DIR"/*; do
  if [-d "$folder/.git"]; then
    output=$(git -C "$folder" pull)
    if ! echo "$output" | grep -q "Already up to date."; then
      echo "[$(basename "$folder")] $output"
    fi
  fi
done
cd ~/discourse
bundle install
pnpm install
bin/rails db:migrate
DISCOURSE_HOSTNAME=localhost UNICORN_LISTENER=localhost:3000 bin/ember-cli -u

```

Then, run:

```bash
chmod +x rundiscourse.sh

```

Then, go to the `~/.bashrc` file (using `nano`, or anything), and add this bit if you don’t already have it (it’s nearer the bottom)

```bash
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [-f ~/.bash_aliases]; then
    . ~/.bash_aliases
fi

```

Then, add the following to the `~/.bash_aliases` file:

```bash
alias discourse="~/rundiscourse.sh"

```

Close your terminal and re-open it.  
Now, when you run `discourse` in the terminal, your development environment should start!

* * *

I hoped this helped! Also, do let me know if I’m doing something wrong, or if it can be improved. Thanks!

---

_[View the full topic](https://meta.discourse.org/t/nice-way-to-run-a-dev-env/375233)._
