In January I posted that I was diving into Linux full-time for my Erlang work.
Erlang itself runs great on Windows, Linux and Mac. I made the shift because most Erlang developers work in Linux and I felt I was probably missing something with my Windows-centric approach. This turned out to be a very valuable exercise. I tried out ErlIDE (Eclipse), a tricked out gedit, Vim, and Emacs. In the end, the best-paved and most productive path for Erlang development appears to be Emacs tricked-out with Erlang goodies and a console standing by for running Rebar and Git commands.
Here’s what my Erlang rig consists of:
- Emacs 23.3
- Erlang mode : Provides syntax highlighting,
- Flymake: shows warnings and errors on the fly as you type like visual studio
- IDO: Adds a good way to browse directories and open files
- color-theme: adds pretty colors and fonts
- Distel: theoretically provides auto-completion, step through debugging and other goodies.
- Key mappings: Adds the key bindings for Cut,Copy,Paste,Alt-F4, Ctrl-Tab that a red-blooded Windows expects.
- Rebar
- Git
A few months in, I realized all of these things should work just fine on Windows. Today I have the same Erlang development rig on both Windows and Linux. This makes me very happy. Why? I’ve mentioned this in previous posts, but I believe C# and Erlang are great complements. Even in a Windows-only .NET shop with no appetite for introducing Linux, there’s no reason to take Erlang off the table. Having a proper Windows tool-chain for Erlang development moves the discussion away from an OS holy war and back to a cost-benefit analysis of Erlang itself. That’s a good place to be.
Each time I’ve done my “Intro to Erlang for C# Developers” talk, folks see my Windows Emacs rig in action and ask “What’s involved in getting that to work?” For anyone who is interested here are the steps:
Get Erlang R14B03
- Download Erlang from here.
- Run the otp_win32_R14B03.exe setup file. By default the installer wants to put Erlang here “C:\Program Files\erl5.8.4″ but change that to “C:\erlang\erl5.8.4\”. OK, but why? Most of the tools and scripts you will use for Erlang development on Windows were crafted over on Linux and the authors may not have tested for spaces in the path (e.g. “Program Files”). Remove that risk.
- Add “C:\erlang\erl5.8.4\bin” to your PATH.
Get Emacs 23.3
- Download Emacs 23.3 from here.
- Right click the zip and “Unblock” it.
- Extract it to a sensible location such as “C:\utility\emacs-23.3″. Again avoid spaces in the path to avoid unnecessary pain.
- Add “C:\utility\emacs-23.3\bin” to your PATH.
- Add an environment variable named “HOME” and give it the value of your home directory (for me this is “C:\Users\bryanhunter”)
- Run Emacs. When it loads it should have a white background, a homely font, and the most hideous splash screen you’ve ever seen.
- Close Emacs.
Pull down my Emacs configuration files [updated 8/27/2011]
- Visit my GitHub repository named ErlangRigEmacsConfig
- Read the readme file
- Download the zip of the repository. This repository contains the “.el” (Emacs Lisp) files that turn plain old Emacs into something pretty nice for Erlang development.
- Right click the zip and unblock it
- Extract it into your home directory (for me this is “C:\Users\bryanhunter”). Note: this needs to match what you put in the HOME environment variable under the Emacs steps.
- Edit your “~/.emacs” file to something like this:
If all went well, when you open Emacs it will show a nice black background screen. If you (or I) missed something, you will see the hideous default Emacs splash screen.
Extra credit #1: Use a prettier font
- Download the lovely “DejaVu” font family from here.
- Unblock the zip and extract it somewhere.
- Open up the “dejavu-fonts-ttf-2.33\ttf\” directory.
- Select all the TTF files and drag them into your “C:\Windows\Fonts” directory.
- Open the “my-config.el” file (it’s in your fancy new Emacs configuration directory).
- Find the line that reads “:family “Consolas”" and replace “Consolas” with “DejaVu Sans”.
- Open the “my-config.el” file (it’s in your shiny new Emacs configuration directory).
- Read it top-to-bottom.
- Tinker, save your changes, reload Emacs.
- Read the “Programming in Emacs Lisp” guide (here) to get smarter.
- GOTO 3
[Note: this post will be in flux until it is correct and complete. Please comment to help me get it there.]


#1 by Lora at August 25th, 2011
| Quote
Excellent post. Excellent enough, I may even attempt a setup, someday. In the meantime, I’m just going to steal your most excellent line–”OS holy war.”
#2 by Ben Henderson at August 25th, 2011
| Quote
Good post, Hunter. Is the “no spaces in path” stuff a pain on Linux, too? Not trying to ignite a war, holy or otherwise, honest.
#3 by Bryan Hunter at August 26th, 2011
| Quote
Ben, it would cause the same pain on Linux. You’re just less likely to see spaces in paths that matter there. That “less likely” part is why to avoid it. It’s an edge case that writers of handy scripts may not have tested or even considered.
Side note: I wish I had a transcript of the whiteboard conversation in which an engineer pitched picking a path with spaces as the default place for all installed software to go. Do a search for “”Program Files” space bug” and you get quite a few hits.
#4 by Calvin Bottoms at August 27th, 2011
| Quote
Thanks for this. I’m giving it a shot. I got a couple of errors indicating that some of the files wanted the ErlangRigEmacsConfig directory to be named emacs-config. I renamed it and got a little further. I get the right color scheme and font now, but I still get an error saying it can’t find file erlang-start.
I know I’m provoking the wrath of the Emacs gods by editing these files with VIM. One holy war at a time.
#5 by Bryan Hunter at August 27th, 2011
| Quote
Calvin, thanks so much for the feedback. I just updated the “ErlangRigEmacsConfig” GitHib project to correct the bogus paths. Re-pull and everything should work now.
My apologies to anyone else who tried and got stuck. Please let me know (here or on Twitter) if you run into problems and I’ll do my best to get you rolling.
#6 by Thomas Lukasik at November 9th, 2011
| Quote
Brian,
Re “#6 Edit your “~/.emacs” file to something like this:”
I cannot find — and neither can several File Search utilities — a file named like this anywhere on my Vista workstation.
Am I misunderstanding something?
Thanks,
TJL
#7 by Thomas Lukasik at November 9th, 2011
| Quote
Re my last comment: in case it matters, please make that “..my Windows 7 workstation” — I forgot that I changed my mind at the last minute
Thanks,
TJL
#8 by Bryan Hunter at November 9th, 2011
| Quote
Thanks for the comment, Thomas.
The “.emacs” file is where customizations go. If you don’t have a ~/.emacs file already, you can just create one in notepad. Make sure to save it as “.emacs” and not as “.emacs.txt” though.
Let me know if you have any trouble.
#9 by Thomas Lukasik at November 9th, 2011
| Quote
Brian,
This is what I’m getting now — any advice:
Debugger entered–Lisp error: (file-error “Cannot open load file” “color-theme”)
require(color-theme)
eval-buffer(#<buffer *load*> nil “c:/Users/tlukasik/emacs-config/my-config.el” nil t) ; Reading at buffer position 277
load-with-code-conversion(“c:/Users/tlukasik/emacs-config/my-config.el” “c:/Users/tlukasik/emacs-config/my-config.el” nil t)
require(my-config)
eval-buffer(# nil “c:/Users/tlukasik/.emacs” nil t) ; Reading at buffer position 65
load-with-code-conversion(“c:/Users/tlukasik/.emacs” “c:/Users/tlukasik/.emacs” t t)
load(“~/.emacs” t t)
#[nil “\205\264
TJL
#10 by Bryan Hunter at November 9th, 2011
| Quote
Ah, looks like you extracted the contents of the zip to the path “~/emacs-config/” instead of “~/ErlangRigEmacsConfig/”. I really need to improve the “el” files to not be so picky. For now, rename the directory to “ErlangRigEmacsConfig” (and update your “.emacs” file to match step #6). I think you’ll be OK after that.
I appreciate you digging into this. This thread is inspiring me hop back in. An installer would be nice.
#11 by Thomas Lukasik at December 30th, 2011
| Quote
Bryan,
Renaming the file as suggested got me past the immediate problem — and to the desired black background — but then another error message followed:
Warning (initialization): An error occurred while loading `c:/Users/tlukasik/.emacs’:
File error: Cannot open load file, erlang-start
Starting emacs with the debug option just told me pretty much the same thing:
Debugger entered–Lisp error: (file-error “Cannot open load file” “erlang-start”)
A subsequent search for file ‘erlang-start’ yielded only 1 file: ‘erlang-start.el’ in ‘C:\Erlang\lib\tools-2.6.6.4\emacs’
It looks like either the file name on disk needs to be changed, or the reference to it in the configuration file does — or am I misunderstanding something?
TJL
#12 by Bryan Hunter at December 30th, 2011
| Quote
Ah, I see. My note on where to install Erlang messed you up. By default the installer (otp_win32_R14B03.exe) wants to install Erlang here “C:\Program Files\erl5.8.4″ but a better place is here “C:\erlang\erl5.8.4\”. When I said “C:\erlang\” I meant there instead of “C:\Program Files\”. Wasn’t thinking folks would lop of the ending (erl5.8.4). My bad. I’ll update the post above to make that bit less confusing.
So to your particular problem… the file “~/ErlangRigEmacsConfig/erlang-config.el” looks for “erlang-start.el down in your Erlang directory (lib/tools-2.6.6.4/emacs/). Your install and what it’s looking for don’t jive. The easiest fix: uninstall Erlang and reinstall it to “C:\erlang\erl5.8.4\” and everything should work. Alternatively, you can edit the “~/ErlangRigEmacsConfig/erlang-config.el” to point at your actual location (chop off the “erl5.8.4″).
I have some un-pushed improvements to the rig to make it less “path brittle”. My goal is to release it, a screencast, and an updated post this weekend.
#13 by Thomas Lukasik at December 30th, 2011
| Quote
>> “The easiest fix: uninstall Erlang and reinstall it”
Bryan,
That being the case, it only made sense to install the latest Erlang release.
But FYI: the default, extended path (the “..\erl5.8.4″ part that I’d “lopped off”) is now “..\erl5.9″ in the new release.
So if you’re planning to update your ‘emacs rig’ instructions, you might want to take the latest path into account.
TJL
#14 by Thomas Lukasik at December 30th, 2011
| Quote
Bryan,
There’s one other thing to change if you’re updating your instructions for the latest Erlang release — you not only need to adjust the path in your configuration file from ‘erl5.8.4′ to ‘erl5.9′, but you also have to change the path from ‘tools-2.6.6.4′ to ‘tools-2.6.6.6′ as shown below:
(setq load-path (cons “c:/erlang/erl5.9/lib/tools-2.6.6.6/emacs” load-path))
(setq erlang-root-dir “c:/erlang/erl5.9″)
(setq exec-path (cons “c:/erlang/erl5.9/bin” exec-path))
After installing the latest Erlang/OTP release (R15B) in ‘C:\Erlang\erl5.9′ and making the adjustments to the paths described above, everything worked fine.
TJL