Computer Things
by Erik Hanson

A Doctor To Check Your Development Environment

Sound interesting?

My colleague Eric Saxby and I are available to help automate your development workflow.

Sharing project configuration and practices with a dev team can be tricky. Readme files are nice but become outdated quickly. Setup scripts, Docker, Chef, etc., are inflexible and add an extra layer of complexity.

In between those two extremes is doctor, a script that checks your dev environment and suggests remedies to the problems it finds. If you don’t like the suggested remedy, you can fix the problem some other way.

Setting up a project on a new computer is easy: clone the project from source control and then run doctor; it will tell you what your computer is missing (languages, databases, environment variables, etc.) and suggest a way to fix each problem.

It’s also easy to add new checks and commit them along with your code changes, so you can make code changes that require development environment changes without worrying about breaking other developers’ environments: doctor just runs the check when the developers update from source control, and then suggests a remedy if necessary.

Most importantly, doctor is an alternative to people hesitating to make changes to code because they are worried about breaking other people's development environments.

Here’s a typical doctor session:

% bin/dev/doctor

[checking] homebrew: bundled?... OK
[checking] direnv: installed... OK
[checking] direnv: .envrc file exists... OK
[checking] asdf: installed... OK
[checking] asdf: erlang plugin installed... OK
[checking] asdf: elixir plugin installed... OK
[checking] asdf: nodejs plugin exists?... OK
[checking] asdf: tools are installed... OK
[checking] deps: elixir deps installed? (needed for yarn to compile)... OK
[checking] yarn: up to date... OK
[checking] phantomjs: installed... OK
[checking] postgres: launchctl script is linked... OK
[checking] postgres: running... OK
[checking] postgres: role exists... FAILED

Possible remedy: createuser -s postgres -U $USER
(it's in the clipboard)

In my projects, I typically check:

  • All the different programming languages are installed and at the right version.
  • All the different databases are installed, configured, and running.
  • All the necessary system tools are installed.
  • All the necessary environment variables are set.

I used to write doctor scripts in Bash because it’s ubiquitous and typically doesn’t require any configuration, but recently my business partner and I have built an implementation of doctor plus other workflow scripts in Elixir (medic-ex), and we are now re-writing it in Rust (medic-rs).