# How Sam's Windows development environment is configured

**URL:** https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444
**Category:** Development
**Created:** [5월 10, 2017, 3:49오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444 "2017-05-10T15:49:04Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5월 10, 2017, 3:49오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/1 "2017-05-10T15:49:04Z")

</div>

I wanted to do a post (that I try to keep up to date) with notes about my current dev environment.

> ⚠ This was a setup I WAS using, I no longer really use it I develop on Linux native. This setup though is reasonable if you are on a Windows machine.

### My building blocks

- Windows 10 creators update
- [Wsltty](https://github.com/mintty/wsltty) which I prefer built in bash for windows console
- [VMWare workstation](http://store.vmware.com/store/vmware/en_US/pd/productID.323700100?src=ps_570c41fd1ed2e&kw=vmware%20workstation&mt=e&utm_source=google&utm_medium=ppc&utm_campaign=GS_eBiz_Lead_AMS_US_EN_BR_RLSA_Workstation&k_clickid=8496831c-55e5-47c0-9a78-6ae13e2eac7d&gclid=CjwKEAjw9MrIBRCr2LPek5-h8U0SJAD3jfht7cypaS23Oa1NFDVkZ90QPIsgun1xzZwzBfYUK-JhtBoChTPw_wcB) with latest Ubuntu installed
- [Mobaxterm](http://mobaxterm.mobatek.net/) cause its nice to have an X server
- Vim plus my [vim setup](https://github.com/SamSaffron/vim-setup) installed inside the VM
- [chruby](https://github.com/postmodern/chruby) plus a bunch of rubies for my dev
- [7+ taskbar tweaker](http://rammichael.com/7-taskbar-tweaker) cause Windows makes it annoying to ungroup icons
- [i3wm](https://i3wm.org/) - I use it almost exclusively on my 3 monitor setup

### Hacks

#### A desktop shortcut to my linux VM

I use this shortcut to access my VM - target:

```plaintext
%LOCALAPPDATA%\wsltty\bin\mintty.exe --wsl -o Padding=5 -o Locale=C -o Charset=UTF-8 /bin/wslbridge -C~ -t /bin/bash -c "DISPLAY=0.0.0.0:0.0 ssh -X ubuntu"

```

It adds a bit of 🎇 in that I have nice padding on my terminal and connect my mobax windows manager to the session so I can run stuff like `git gui` if I want.

#### A shortcut to puma

I use a custom shortcut to launch puma:

```plaintext
%LOCALAPPDATA%\wsltty\bin\mintty.exe --wsl -o Padding=5 -o Locale=C -o Charset=UTF-8 /bin/wslbridge -C~ -t /bin/bash -c "ssh ubuntu '(cd /home/sam/Source/discourse && echo `pwd` && . ~/.zshrc && cd ~/Source/discourse && bin/puma --kill-existing)'

```

This shortcut is pinned to my taskbar and allows me to easily launch puma when needed and easily find it.

 ![](https://global.discourse-cdn.com/meta/original/3X/2/0/20b462f68d964fd2bbad3ac37c739937bf1f3dee.png)

#### Using Chrome directly in Windows to access dev

I prefer running Chrome in Windows to running it in X Windows, I prefer the rendering Windows provides and it just works a bit faster in this setup.

I have it configured so `ubuntu` always resolves to my VM ip, I handle that by providing VMWare a static lease for the VM [per this article](https://bytealmanac.wordpress.com/2012/07/02/assigning-a-static-ip-to-a-vmware-workstation-vm/).

It basically means I edit:

`C:\ProgramData\VMware\vmnetdhcp.conf`

And add something like this to the conf

```plaintext
host ubuntu {
    hardware ethernet 00:0C:29:16:2A:D6;
    fixed-address 192.168.84.132;
}

```

Once that is done and my `c:\Windows\System32\Drivers\etc\hosts` file is edited to reflect, I can access my dev env using `ubuntu` instead of shuffling IPs. The IP is stable on reboot so this just works once setup.

 ![](https://global.discourse-cdn.com/meta/original/3X/1/d/1dd43b4843a16b6214b2ceaf597c4cc31a983774.png)

#### Seamless SSH from WSL to VM

I generated an RSA key in my WSL instance and use `ssh-copy-id` to stage the public key to the Linux VM.

This means I do not enter passwords when I `ssh` into the VM using the above shortcuts, this is critical to this workflow.

#### Better errors support

[Better errors](https://github.com/charliesome/better_errors) is the awesome gem that makes debugging in dev so much easier. Unfortunately, out of the box, it is super strict about who is allowed access.

I use a 🔨 to allow my Windows machine access to `http://ubuntu:9292/__better_errors` by adding this to my `.zshrc`:

```plaintext
export TRUSTED_IP:"0.0.0.0/0"

```

Feel free to use less of a sledgehammer, but completely losing out on better errors would be a huge shame.

#### Vim autospec

I use the Vim autospec configuration documented here: [discourse/bin/notify\_file\_change at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/bin/notify_file_change)

This means that as soon as I save a spec, autospec runs it using the power of 🎩

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [5월 10, 2017, 3:51오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/2 "2017-05-10T15:51:43Z")

</div>

Thanks, @sam. Does anyone run a native Ubuntu dev environment? (Or maybe it’s so easy that it’s not worth documenting.)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5월 10, 2017, 3:56오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/3 "2017-05-10T15:56:25Z")

</div>

@techAPJ does and @tgxworld but it is far less fiddly.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [5월 10, 2017, 4:02오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/4 "2017-05-10T16:02:21Z")

</div>

I pretty much still follow this guide:

> [@Install Discourse on Ubuntu or Debian for Development](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727):
>
> warning This guide covers installation instructions in a development environment. For a production guide see: [Install Discourse in production with the official supported instructions](https://meta.discourse.org/t/how-to-install-discourse-in-production/142537) So you want to set up Discourse on Ubuntu or Debian to hack on and develop with? We’ll assume that you work locally and don’t have Ruby/Rails/Postgres/Redis installed on your Ubuntu or Debian system. Let’s begin! Requirements We suggest having at least 4 GB RAM and 2 CPU cores. Current compatibility: O…

🙂

For headless installation of Discourse dev-env on Ubuntu, I recommend using our official Docker dev image: [https://github.com/discourse/discourse/tree/master/bin/docker](https://github.com/discourse/discourse/tree/master/bin/docker)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [5월 10, 2017, 4:06오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/5 "2017-05-10T16:06:05Z")

</div>

> [@techAPJ](#):
>
> I recommend using our official Docker dev image:

Oh! That’s gold. I’d been rolling my own. Now I’m glad I asked. 🙂 That might deserve its own topic.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [5월 10, 2017, 7:35오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/6 "2017-05-10T19:35:19Z")

</div>

I notice that your dev environment has the content of try. Is that something mere mortals can get, for starting out with a pre-populated test space?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5월 10, 2017, 7:45오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/7 "2017-05-10T19:45:16Z")

</div>

I would love to have a test database out there that anyone could download, unfortunately try would need a bit of scrubbing (emails / ips) if you feel like taking on such a project let me know 😉

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [5월 10, 2017, 7:57오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/8 "2017-05-10T19:57:02Z")

</div>

If @elijah does not want to take on the project, I’d be happy to once I finish my current project.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [5월 10, 2017, 8:26오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/9 "2017-05-10T20:26:28Z")

</div>

Yeah, I think I could do that.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [6월 15, 2017, 7:13오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/10 "2017-06-15T19:13:23Z")

</div>

Any progress on this?

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [6월 15, 2017, 10:50오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/11 "2017-06-15T22:50:28Z")

</div>

I’ve got code that reads the database dump and creates a new dump.sql with _almost_ entirely new content, and generates a whole set new placeholder images.

But the restore didn’t like my dump.sql and I need to track down where I screwed it up.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [6월 18, 2017, 2:49오전 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/12 "2017-06-18T02:49:14Z")

</div>

The first error in the log (`/var/lib/dockers/containers/idhere/idhere.json`) is:

```json
{"log":"2017-06-18 02:16:36.036 UTC [2492] discourse@discourse ERROR: relation \"api_keys\" already exists\r\n","stream":"stdout","time":"2017-06-18T02:16:37.497495095Z"}
{"log":"2017-06-18 02:16:36.036 UTC [2492] discourse@discourse STATEMENT: CREATE TABLE api_keys (\r\n","stream":"stdout","time":"2017-06-18T02:16:37.510775323Z"}

```

In the restore progress window in the browser everything leading up to that looks like:

```plaintext
[2017-06-18 02:16:33] 'eli' has started the restore!
[2017-06-18 02:16:33] Marking restore as running...
[2017-06-18 02:16:33] Making sure /var/www/discourse/tmp/restores/default/2017-06-18-021633 exists...
[2017-06-18 02:16:33] Copying archive to tmp directory...
[2017-06-18 02:16:33] Unzipping archive, this may take a while...
[2017-06-18 02:16:35] Extracting metadata file...
[2017-06-18 02:16:35] Validating metadata...
[2017-06-18 02:16:35] Current version: 20170605014820
[2017-06-18 02:16:35] Restored version: 20170307181800
[2017-06-18 02:16:35] Extracting dump file...
[2017-06-18 02:16:35] Restoring dump file... (can be quite long)
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] SET
[2017-06-18 02:16:36] ERROR: relation "api_keys" already exists

```

Which is making me think, not a syntax error. That’s the first `CREATE TABLE` statement in the file. I understand that during restores there’s supposed to be some `CREATE SCHEMA` / `RENAME SCHEMA` magic that goes on (eg [Restore a Discourse backup manually for development](https://meta.discourse.org/t/manually-restoring-a-discourse-backup-for-development/33551) ), but I don’t see that in the Docker log, the less verbose on screen restore log, or inside the dump.sql file.

I thought that might be the problem, so I manually put in

```sql
DROP SCHEMA IF EXISTS restore CASCADE;
CREATE SCHEMA restore;

```

Without luck.

Is this process sound? It’s how I set things up:

```bash
mkdir /var/discourse /var/hold
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
./discourse-setup
# errored out because of mail config,
vi container/app.yml

tar cf - . | gzip > /var/hold/fresh-install.tgz

```

And then restore them between runs:

```bash
cd /var/discourse
./launcher stop app
rm -rf ./* /var/lib/dockers/containers/*
tar xzf /var/hold/fresh-install.tgz
./launcher rebuild app
mkdir -p /var/discourse/shared/standalone/backups/default
cp /var/hold/backup.tgz /var/discourse/shared/standalone/backups/default/try-begriffin-2017-03-09-145156-v20170307181800.tar.gz

```

Then I have to go into the web browser and create my admin account, enable restores, and try to restore the backup.

But that should reset everything past initial docker install, right?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [6월 18, 2017, 4:17오전 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/13 "2017-06-18T04:17:41Z")

</div>

> [@elijah](#):
>
> [2017-06-18 02:16:35] Current version: 20170605014820  
> [2017-06-18 02:16:35] Restored version: 20170307181800

This looks backwards to me, are you restoring older over newer?

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [6월 18, 2017, 6:24오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/14 "2017-06-18T18:24:04Z")

</div>

Yes. Is taking a backup from an old system and putting it on a newer one not supported?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [6월 18, 2017, 8:35오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/15 "2017-06-18T20:35:45Z")

</div>

No that is not supported.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [6월 18, 2017, 9:57오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/16 "2017-06-18T21:57:11Z")

</div>

Uh no, that’s migrating forward. It’s taking a backup from current and restoring it onto old that’s bad.

---

<div class="post-metadata">

### Author: ![sarahann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sarahann/32/96703_2.png) [@sarahann](https://meta.discourse.org/u/sarahann)
#### Post date: [6월 8, 2018, 1:14오전 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/17 "2018-06-08T01:14:42Z")

</div>

Is this the recommended setup for windows?

Also, are you able to debug in the VM? Set breakpoints and such?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [6월 8, 2018, 1:31오전 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/18 "2018-06-08T01:31:11Z")

</div>

Recommended is a funny word 🙂 This is the setup I still use and still love. I have a Win 10 desktop with 3 4k monitors and while coding I dedicate 2 to my VM.

I find Vim + i3wm to be a killer excellent combo. Debugging wise [I am a puts debugger](https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html). Combined with `bin/rake autospec` which works on plugins and has Vim integration where I auto focus on the running spec, I have a lethal and highly effective combo.

I would not say my setup is for everyone though, but … if you go down this path a lot of gold awaits at the end of the rainbow. 🌈

---

<div class="post-metadata">

### Author: ![mreach](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mreach](https://meta.discourse.org/u/mreach)
#### Post date: [11월 2, 2019, 6:57오후 UTC](https://meta.discourse.org/t/how-sams-windows-development-environment-is-configured/62444/19 "2019-11-02T18:57:02Z")

</div>

`Vim`을 `emacs`로만 바꾸면 골드 레벨이 10배로 올라갑니다… 😉

[![](https://global.discourse-cdn.com/meta/original/4X/2/5/d/25dca05aee130cf79d3e1763443afc3afaa6a294.jpeg "Emacs or VI: The Definitive Answer.") ](https://www.youtube.com/watch?v=V3QF1uAvbkU)
