Elixir Development on Windows 10

Hi all,

I just published a post on Medium on developing Elixir/Phoenix on Windows 10. I thought it might be useful to others.

Rod

5 Likes

I’ve been dev’ing with Elixir on Win10 for a few months now but still not setup Chocolatey or the VS stuff (I use mingw for things here), convenient to get that installed though for if I run into any native code. Thanks for the commands. :slight_smile:

Found some bugs, a lot of your quotes in code blocks are not quotes but something else (), they should be ("), will make things fail pretty bad.

EDIT1: For example, the .iex.exs block should probably be like:

Application.put_env(:elixir, :ansi_enabled, true)
IEx.configure(
  colors: [
    enabled: true,
    eval_result: [:cyan, :bright]
  ],
  default_prompt: [
    "\e[G", # ANSI CHA, move cursor to column 1
    :darkblue,
    "%prefix", # IEx prompt variable
    ">", # plain string
    :reset
  ] |> IO.ANSI.format |> IO.chardata_to_string
)

EDIT2: And the above code spits out:

iex(1)> Error while evaluating: c:/Users/<user>/.iex.exs
iex(1)> ** (ArgumentError) invalid ANSI sequence specification: :darkblue
iex(1)>     (elixir) lib/io/ansi.ex:167: IO.ANSI.format_sequence/1
    (elixir) lib/io/ansi.ex:218: IO.ANSI.do_format/5

EDIT3: And indeed :darkblue is invalid: https://github.com/elixir-lang/elixir/blob/v1.3.2/lib/elixir/lib/io/ansi.ex#L74-L168

EDIT4: And changing it to :blue appears to make no change to the iex terminal, still uncolored and unformatted, hmm. I’ve never messed with the iex terminal, only some default imports and such…

Thanks. Pasted the wrong code sample will fix.

Ahh, awesome!

EDIT1: Ahh the iex prompt does not change until any input is put in, ‘then’ it is updated, seems like a bug in iex. I like the color distinctions. :slight_smile:

Yah, it’s seems to be a bug. I meant to leave that part out as its not quite working. Maybe I’ll put it back and add a warning.

1 Like

Fixed the quotes now. Copy and paste error.
Thanks for catching those. Gave you credit in the article.

1 Like

Hi, I’m the maintainer of Comeonin, and it’s great to see posts like this. It’s good to have more detailed information for Windows users.

2 Likes

Also another bug (I think with iex, not your article, but probably want to mention this too), if you spool up iex with --sname or --name then the prompt will not be colored (although output will). I was not able to find a quick way to resolve this issue, but like stated, seems like an iex bug. :slight_smile:

I seem to have posted this reply under the wrong post, it was meant for you @rodwatkins

Let me look into it. I am not at my machine at the moment, but I’ll see if I can get it to compile when I am.

Cheers
rod

@ibgib

For a windows user, how has your experience been?
What is your Linux-tools setup? msys64, Virtual-box Ubuntu or something else?

Also, do you have a go-to setup for running elixir successfully on windows?

The Elixir Windows community could really do with some official step-by-step guidance on setting up a (near) perfect windows environment for Elixir, that can handle ANY Linux / make compilation issues.

1 Like

I never made a step-by-step but here is how I made it work, roughly (NOTE: It requires at least Windows 10 Anniversary Edition be installed):

  • Install the Chocolatey Windows package manager.
  • Install Erlang via choco install erlang in an elevated CMD shell. (SIDE NOTE: I use ConEmu64 as a shell, makes life much easier and nicer on the command line in Windows)
  • You can choose between choco install elixir next, or to manually download it from the Elixir releases. I prefer the latter since the maintainer of the Elixir package in Chocolatey doesn’t seem fast, and manual install of Elixir is as simple as extracting a ZIP + adding an entry in your PATH environment variable.

It’s easy from there on. The only possible issues are Git and SSH. I use msysgit 2.x but I had trouble with it and can’t really vouch for it. SSH is just fine if you use PuTTY or KiTTY (or any other fork really) however, but a proper Git setup in CMD is something I never really chased fully.

1 Like

Using this setup, what has been your experience with make?

Have you successfully used / compiled the Ranch Erlang module? or any other Erlang modules that have a make compilation step?

This is where my Elixir on windows experience breaks down.

Apologies for misunderstanding, I didn’t mean to pollute.

As far as make goes, Windows hasn’t really progressed much during the last 10 years. You can always use Cygwin or various GNU Windows environments (Mingw, UnxUtils etc.) but frankly, I believe our best bet for now is to sort of bypass Windows and just use Bash on Ubuntu on Windows 10 (the native Ubuntu inside it).

(Trouble with this approach however is that Erlang/OTP 19.0 and 19.1 don’t work; you have to use 18.0, at least for the time being)

You are correct, @svarlet, sorry.

@AstonJ or another mod – could you please move mine and @CharlesO’s replies to this thread? Elixir Development on Windows 10

…done :slight_smile:

2 Likes

I no longer am using Windows because I found that setting up Ubuntu + Erlang was actually quite easy and painless. I started off with Hyper-V and Ubuntu VMs, and then gradually transitioned myself to running it on bare metal as my experience with VMs in Ubuntu has been less than fruitful. Then I found Elixir and this made the process even easier, since Elixir does documentation so ridiculously well. :heart:

As for my current tooling, I point you to the Atom thread. Emacs has too many chords for my taste,
and I’ve become more adept at Vim, but I’ve found Atom to be the most productive. I also use VS Code some when working on the javascript side of things.

(Thanks for moving this question @AstonJ…I had asked that it be moved when starting to write this thing!)

Hey! I know the last reply here been a while but I hope you can help me…

I’ve been setting up my elixir environment as described in the article but got two problems with credo:

  1. It does show some strange characters instead of vertical lines and symbols and no colors. Color in iex work fine. I guess there’s something I need to configure or install for it to work in the command line (I’m using cmder) :

    mix credo

    Code Readability
    Ôöâ
     [R]  Modules should have a @moduledoc tag.
    Ôöâ lib/credo-test.ex:1:11 #(CredoTest)

    Consistency
    Ôöâ
    Ôöâ [C] Ôåù File is using windows line endings while most of the files use unix line
    Ôöâ endings.
    Ôöâ lib/credo-test.ex #()

    Please report incorrect results: Issues · rrrene/credo · GitHub

    Analysis took 0.1 seconds (0.01s to load, 0.09s running checks)
    3 mods/funs, found 1 consistency issue, 1 code readability issue.

    Showing priority issues:    (use --strict to show all issues, --help for options).

  2. It does not show the credo results in linter. It always shows “0 0 0” (see screenshot below)

I’m new to atom and elixir, so please be patient and nice with me :wink: Hope someone can help me solve my problems.

The atom-credo-linter is fundamentally broken by design. It will not work unless you are using a linux system (not even mac, well, but sometimes it will…) and are on an english locale and mix is installed at a certain location where it was found by the creator of the plugin.

Also the creator of the pliugin does not use atom by himself, so the problems will probably never get fixed: https://github.com/smeevil/linter-elixir-credo/issues/10#issuecomment-257242841