So as many of you will know I’m very interested in Elixir. I also want to see it work better on Windows. There are a few of us that have been working on it.
I’ve also been very interested in how one can deploy an Elixir app on a machine which doesn’t have Erlang and Elixir already installed. While most of us don’t mind having to have Erlang and Elixir around because we are doing development work, it would be much more secure to only have to deploy the binaries that need to be deployed for an app.
Since I started on Elixir one of the nicest folks in the community (and that’s saying something) has been Paul Schoenfelder. When I was first struggling to learn Elixir, Paul very patiently helped me to get started. So I became aware of one of the utilities that Paul built: EXRM. Exrm is a tool to automate the production of a package of the needed Elixir and Erlang binaries to deploy an app. It allows a developer to deploy his or her Elixir app with only the needed runtime files so that the target machine doesn’t have to have Elixir or Erlang installed.
So I asked Paul what I could do to sort of return the favor for the help he gave me when I started and he mentioned that he wasn’t as pleased as he might be with the support for Windows in EXRM. So I started digging into EXRM to see what I might do to get it working on Windows.
A few instructive things I spotted right away. I noticed that the way the Windows batch files were constructed they will not work correctly if they’re not run from the correct directory. I mention this for others who may try to use EXRM on Windows.
Spaces In Directory Names
I noted also that there were several places where directories containing spaces and too many characters were also a problem. The original developers of the batch files wrapped double quotes around all the directory names. If you decide to build Windows batch files, please note that wrapping double quotes around directory names is a bit error prone and tough to get right. Hence I opted to modify all the various places where they had double quoted directory names to using 8.3 versions of the names. That fixed up all the references to directories so that everything was found correctly.
Getting Services Working
Next there was the question of getting Windows Services working for Erlang. While digging into the batch files I discovered that basically the issue hinged on the installation of the service. Once the service was installed correctly, it looked as if the rest of the operations on the services (starting, stopping, restarting etc.) would work correctly.
I had to hunt around for a while to figure out what I needed to do to get the service to install correctly. I finally figured out that what was happening was the wrong parameter was getting passed as the binary to be started when the service gets started. And so I repaired it.
A Few More Details
You’ll also need to unblock the erl.exe and epmd.exe files for the Windows Firewall. You can wait for Windows to prompt you or you can proactively unblock them via this escript.
You may also need to deploy msvcr100.dll to your deployment machine as well. If it’s a Windows 10 machine you may need to do this.
So we’re almost ready to roll the changes into EXRM so we can get people to be able to deploy Elixir apps on Windows.
I will continue to work with Paul on improving support for EXRM on Windows. Keep watching this space; we’ve got some interesting ideas we’ll be trying to roll out in the next few months or so.