Cygwin for compiling

Here we go:

$ ls -l /cygdrive/c/elixir/bin
total 31
-rwxrwx---+ 1 Administrators Domain Users 3819 Dec  3 23:00 elixir
-rwxrwx---+ 1 Administrators Domain Users 4673 Jan  5 11:32 elixir.bat
-rwxrwx---+ 1 Administrators Domain Users 1030 Dec  3 23:00 elixirc
-rwxrwx---+ 1 Administrators Domain Users 1094 Dec  3 23:00 elixirc.bat
-rwxrwx---+ 1 Administrators Domain Users 2199 Dec  3 23:00 iex
-rwxrwx---+ 1 Administrators Domain Users 2369 Dec  3 23:00 iex.bat
-rwxrwx---+ 1 Administrators Domain Users   45 Feb 21  2016 mix
-rwxrwx---+ 1 Administrators Domain Users   95 Dec  3 23:00 mix.bat
-rwxrwx---+ 1 Administrators Domain Users  576 Oct 19  2015 mix.ps1

OK, there seems to be something weird going on…

I can’t say for sure, so this is a guess and might be not what is really happening, but I will provide the steps necessary to check.

I think, that for some reason mix.bat is started instead of mix, it is able to start elixir in an environment that is not cygwin aware anymore, so elixir is not able to find /cygdrive/c/elixir/bin/mix, because it simply doesn’t exist in that context.

When one tries to start elixir with a file that does not exist a similar message appears, this is the main reason to think this:

$ elixir foo
No file named foo

To actually check if my theory is correct, you can do the following:

$ mv `which mix`.bat `which mix`.bat.bak
$ mv `which mix`.ps1 `which mix`.ps1.bak

This should rename that bat and powershell wrappers and so again the system should not find and run them anymore and mix should work again.

But mix will not be available anymore from standard windows command prompt, but cygwin only.

If you need to revert that change you can do the following:

$ mv `which mix`.bat.bak `which mix`.bat
$ mv `which mix`.ps1.bak `which mix`.ps1

Personally I do not use cygwin as POSIX-wrapper anymore for about 2 years now, since there were problems everywhere. I had a much better success story after switching to MINGW64.

First of all, thanks so much for response. I installed MINGW64 and now, how can I execute it?

1 Like

I downloaded and try to execute iex and does not work.

Then I try to install elixir with

pacman -S elixir

and as result:

$ pacman -S elixir
error: target not found: elixir

What am I doing wrong?

Well, MSYS2 has no elixir package, so you need to compile it by yourself. I’d only recommend this when you have a Unix/Linux background and you can install elixir and erlang by hand over there already or you will destroy your mingw env before it was even properly set up.

Before switching into just another unknown terrain, please check if that workaround with moving bat and ps1 away does work.

No, it does not work. Sorry. Which bash is easy to use? How to use with MINGW64?

A native bash running under linux is the easiest, but you already mentioned the impossibility for you.

So I will give you some options, in no particular order

  • Install Ubuntu in a virtual machine. Might involve massive hard disk overhead and some time to set it up to your needs.
  • Install Vagrant and use it. For a phoenix project of mine I did once create a Vagrantfile which sets up an image which has all necessary stuff available on a CentOS 7 guest. I will try to extract necessary parts and post it somewhere when I am back home and my older son is in bed (about 6 hours from now)
  • A POSIX-Wrapper that actually works :wink: But unfortunately I do only know Cygwin which had many flaws back than and MSYS2/MingW64 which I’d only recommend to people familiar with linux‌.
  • An alias in ~/.bashrc, roughly like this: alias mix="/cygdrive/c/elixir/bin/elixir c:/elixir/bin/mix". After you changed your ~/.bashrc, you need to restart all open bash-sessions or re-source ~/.bashrc to make that change happen.

The last one might be the easiest, but before that try it out directly: /cygdrive/c/elixir/bin/elixir c:/elixir/bin/mix, if and only if this will get you the expected output of mix, you can insert that line from above in your RC-file and go for it.

I tried it and it does not work at all. I will start to cry. I hate windows.

What did you try and which errormessage did you got?

The same error message.
I think I should switch to ubuntu.

In the command I gave you, there is no “/cygdrive/c/Elixir/bin/mix”, so the error message can’t be the same unless something is really borked!

Sorry if I sounded a bit harsh. But I really try to figure out where this message comes from and why. So the exact messages as they are printed to your console are crucial information.

Maybe we can even find a final solution here and on top of that report a bug upstream, fix included (or some warnings at least).

Uh, I may have missed the reason, but why use cygwin with elixir? I use just a windows bash install (mingw64 I think, and even then only because I am more comfortable with linux tools than Windows ones) and the stock command prompt and powershell without issue. Cygwin sets up a very…odd environment on Windows.

What happens if you do mix in a normal windows command prompt without the prior post listed renames?

It works as expected. But working with powershell is not a pleasure at all. That why I switched to cygwin.

1 Like

Try to use the only one true console for windows (git and some linux commands included ) :wink:

Well, cmder is just a fancy GUI for PowerShell and cmd.exe, still no POSIX-stuff available. Still that ugly MS-Tooling, which might be powerfull but ugly to use…

Whenever I search for something that is an alternative for a well known and easy understandable BASH/ZSH one-line command, I will end up defining just another script for PowerShell, having a couple of lines and fighting myself against execution policy stuff, since it seems as if I’m not allowed to run anything except microsoft scripts by default.

And this things that make working with PowerShell a bad experience aren’t touched by (or in scope of) cmder.

But cmder has (with Git BASH)

-> so some linux commands and git support

Git for Windows provides a BASH emulation used to run Git from the command line. *NIX users should feel right at home, as the BASH emulation behaves just like the “git” command in LINUX and UNIX environments.

Alternative there is Windows 10 bash (not tested it yet)
You can install powershell on linux also :wink:

Well, git-for-windows/git bash is just a preconfigured mingw and focused on its job to provide git in windows. When you want to install additional software you have to either install them under windows and fiddle git-bash’s PATH or you have to do a sourceinstall in git-bash which sometimes makes the software in question unusable outside of the git-bash context.

But I have to admit, I might take a look at clink when I have some time to spare :wink: Thank you for that


There is this topic

And this article

I had a good experience with cmder when I was working with nodeJS/AngularJS on Win7 - that being said it still didn’t stop me from moving to Arch (dual boot with Win10) for developing with OSS - so I never used it with Elixir.

However I would try it on a Win10 image that hasn’t been potentially compromised with the Cygwin situation.

As @NobbZ already stated cmder smoothes over some bumps but it isn’t *nix-on-win (which kept me pushing towards Arch) - but sometimes cmder is “good enough”.


Nice article except I prefer Visual Studio Code / Spacemacs … :slight_smile:

Another vote here for cmder/conemu on Windows, I use it at work. :slight_smile: