On windows I got "could not compile dependency :bcrypt_elixir"

When I install the module “bcrypt_elixir” I get the following error:

mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elixir" or clean it with "mix deps.clean bcrypt_elixir"
==> appx
** (Mix) "nmake" not found in the path. If you have set the MAKE environment variable,
please make sure it is correct.

I do not know how to fix it.

My deps function:

defp deps do
      {:phoenix, "~> 1.3.0"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_ecto, "~> 3.2"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.10"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:gettext, "~> 0.11"},
      {:cowboy, "~> 1.0"},
      {:comeonin, "~> 4.0"},
      {:elixir_make, "~> 0.4.1"},
      {:bcrypt_elixir, "~> 1.0"}

You probably need a visual studio, cygwin or msys2 to compile the NIFs.

1 Like

Basically what NobbZ said, you need a C compiler installed. The bcrypt docs
point you to the comeonin wiki for details (see the Requirements wiki page).


If you get the Visual Studio tools and launch a cmd shell with the right bat file that sets paths, you can properly build things like comeonin and bcrypt. It’s a stupid pain, but with some fiddling it works.

You can use chocolatey to install the Visual Studio build tools, or you can just install them yourself from MS downloads. But the critical step is start a cmd shell running the appropriate script so you get nmake in your path.

cmd /K ‘C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat’

I had this working previously where I could use PowerShell, but it mysteriously broke and now I’m stuck with CMD.exe. Whatever, it’s Windows, so the fact that you can actually build is a miracle.

1 Like

Here’s what I have working now. I have a file called wcmd.cmd that I run which sets up the paths and stuff for the VC tools and launches a PowerShell as administrator.

wcmd.cmd file contains:

@CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" %*
powershell -Command "Start-Process PowerShell -Verb RunAs"

I used to be able to just double click and run that and end up with a PowerShell that would successfully mix compile, but for some reason that stopped working. Now I have to launch a PowerShell as admin, then go type
and hit return. That will run the script and launch a PowerShell with nmake visible. That’s the shell you use to develop in.