Craftsman at work

I'm Artur Karbone, coding software architect and independent IT consultant and this is my blog about craftsmanship, architecture, distributive systems, management and much more.

Elixir/Phoenix on Windows

Installation part

Recently I attended LatCraft Elixir focused workshop by Boris Goriachev. It's been a while since I've touched Elixir. In addition to that only Windows machine was available to me at the time, so I had to setup Elixir/Phoenix from scratch.

If you are not using Chocolatey package manager, give it a try. A great tool for automating software installation/provisioning. Btw. I recently blogged about how to provision .NET Core environment with Chocolatey.

Moving along. I assume that you have Chocolatey installed. Then run the following script:

choco install elixir  
mix local.hex  
mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez  

CD to the directory of your choice, bootstrap Phoenix project and launch it

mix phoenix.new .  
mix phoenix.server  

Gotchas

I don't remember having such kind of issues working on Mac/Linux even before Elixir was 1.0, but surprisingly I faced them on my Win10 machine:

clear()

I was not able to clear screen via clear() in iex console. I kept getting : "Cannot clear the screen because ANSI escape codes are not enabled on this shell". Looks like the solution to call this command within the iex session:

Application.put_env(:elixir, :ansi_enabled, true)  

saved the day.

autocomplete

I may laugh at it, but it is not possible to leverage an amazing autocomplete feature pressing a tab key withing iex session out of the box. As this GitHub issue recommends, iex should be called with a special argument:

iex --werl  

Which launches Erlang Shell. If you like the shell you can stop and live right there. My next step, though, would be trying iex stuff from Docker on Windows and enjoy all the Elixir native goodies.

Workshop repos

https://github.com/jesteracer/latcrft_intro

https://github.com/jesteracer/latcrft_battleshp

comments powered by Disqus