When should you automate development environment setup?

Have you ever started to build something on your personal machine and found that you’re missing one of your dev tools? Maybe you’ve started working at a new company and spent days getting your machine setup with the proper tools and configuration that you like? Scripting your development environment setup can help you get setup quickly on new machines, or keep your tools synced across multiple machines.

If you’re in charge of building machines for developers, I strongly recommend implementing this in some form. Design a process for building machines preloaded with developer settings and programs. Perhaps a company wide settings build, with each developer team building a script for new hires. This will save your company a lot of time and money.

I’m a big fan of automating your dev environment setup. Hopefully you see the benefits of it as well.

Personal Machine – Starting fresh

Starting fresh! automate development environment

Starting fresh! automate development environment

It’ll be pretty hard to automate your setup if you don’t ever have to start fresh. In fact, if you never have to start fresh, you probably don’t need to do this. One day you’ll get a new machine, or your old machine will need to be reformatted. When this happens, get ready. We’re about to prevent the sadness of a clean start from happening ever again.

Script EVERYTHING

When you’re setting up your new machine, don’t run commands willy nilly in the terminal, write them in a script file. If you adjust a settings file, like a .bashrc or some other dot file, script that change. If you don’t want to script file concatenations, I recommend storing a current version of the dot file in a folder that is under version control. This way you can use git clone in your setup scripts and then symbolic link your dot files to the files you cloned from git.

Test your scripts

Your scripts should be safely repeatable. Run them and make sure all your programs are installed and working correctly. Make sure you keep an eye out for terminal errors while they are running. If you scripted some symbolic links, or if you clone projects from version control, make sure your script can handle if the folders already exist.

Stay organized

Try to keep your scripts organized and easy to maintain. I like to break my setup scripts into separate script files.

I have scripts for :

  • Installing programs
  • Setting up environment variables
  • Setting up color schemes and fonts
  • Setting up vim and all my vim plugins
  • Running all the other scripts

Challenges

This is a tough thing to do. You probably won’t get it 100% perfect, but try and get as close as you can without wasting too much time. The goal is to have a collection of scripts that can get you up and rolling on a new machine within 2 to 3 hours. Once you get these scripts setup, you can commit them to version control, and run them on all your machines when your config changes.

Example config

If you’d like to see my simple setup click here