trenpixster / addict

User management lib for Phoenix Framework
MIT License
645 stars 99 forks source link

Comeonin dependency error on Windows #47

Closed mesosteros closed 9 years ago

mesosteros commented 9 years ago

I tried installing addict in my Phoenix Project however I'm getting an error. I tried the exact same process on a colleague's Mac OS X and he does not get the error, while I on Windows do. The error comes from the comeonin dependency. I've also tried it in both Phoenix 0.14 and the 0.15 update that was released yesterday.

Steps to recreate:

  1. Create a new project and run it
$ mix phoenix.new testAddict
$ cd testAddict
$ mix ecto.create
$ mix phoenix.server
  1. Add addict in mix.exs:

defp deps do [{:phoenix, "~> 0.15"}, {:phoenix_ecto, "~> 0.8"}, {:postgrex, ">= 0.0.0"}, {:phoenix_html, "~> 1.4"}, {:phoenix_live_reload, "~> 0.5", only: :dev}, {:addict, "~> 0.0.5"}, {:cowboy, "~> 1.0"}] end

  1. Compile dependencies:

    $ mix deps.get

Results:

Running dependency resolution
Dependency resolution completed successfully
  addict: v0.0.5
  comeonin: v0.11.3
  mailgun: v0.0.2
* Getting addict (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/addict-0.0.5.tar)
Using locally cached package
Unpacked package tarball (c:/Users/mesos_000/.hex/packages/addict-0.0.5.tar)
* Getting mailgun (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/mailgun-0.0.2.tar)
Using locally cached package
Unpacked package tarball (c:/Users/mesos_000/.hex/packages/mailgun-0.0.2.tar)
* Getting comeonin (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/comeonin-0.11.3.tar)
Using locally cached package
Unpacked package tarball (c:/Users/mesos_000/.hex/packages/comeonin-0.11.3.tar)
  1. Run Phoenix project again:

    $ mix phoenix.server

Results (here's the error):

==> mailgun
Compiled lib/mailgun.ex
Compiled lib/client.ex
Generated mailgun app
==> comeonin
could not compile dependency comeonin, mix compile failed. You can recompile this dependency with `mix deps.compile comeonin` or update it with `mix deps.update comeonin`

** (ErlangError) erlang error: :enoent
    (elixir) lib/system.ex:440: System.cmd("nmake", ["/F", "Makefile.win", "priv\\bcrypt_nif.dll"], [stderr_to_stdout: true])
    mix.exs:15: Mix.Tasks.Compile.Comeonin.run/1
    (elixir) lib/enum.ex:977: anonymous fn/3 in Enum.map/2
    (elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir) lib/enum.ex:977: Enum.map/2
    (mix) lib/mix/tasks/compile.all.ex:15: Mix.Tasks.Compile.All.run/1
    (mix) lib/mix/tasks/compile.ex:64: Mix.Tasks.Compile.run/1
    (mix) lib/mix/tasks/deps.compile.ex:105: anonymous fn/2 in Mix.Tasks.Deps.Compile.do_mix/1
  1. Attempt suggestions:

    $ mix deps.compile comeonin

Results:

Running dependency resolution
Dependency resolution completed successfully
  comeonin: v0.11.3
$ mix phoenix.server

Result: same error as above.

$ mix deps.update comeonin

Results:

==> comeonin
could not compile dependency comeonin, mix compile failed. You can recompile this dependency with `mix deps.compile comeonin` or update it with `mix deps.update comeonin`

** (ErlangError) erlang error: :enoent
    (elixir) lib/system.ex:440: System.cmd("nmake", ["/F", "Makefile.win", "priv\\bcrypt_nif.dll"], [stderr_to_stdout: true])
    mix.exs:15: Mix.Tasks.Compile.Comeonin.run/1
    (elixir) lib/enum.ex:977: anonymous fn/3 in Enum.map/2
    (elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir) lib/enum.ex:977: Enum.map/2
    (mix) lib/mix/tasks/compile.all.ex:15: Mix.Tasks.Compile.All.run/1
    (mix) lib/mix/tasks/compile.ex:64: Mix.Tasks.Compile.run/1
    (mix) lib/mix/tasks/deps.compile.ex:105: anonymous fn/2 in Mix.Tasks.Deps.Compile.do_mix/1
mesosteros commented 9 years ago

Tested in my Ubuntu VM and also got a similar result:

==> comeonin
could not compile dependency comeonin, mix compile failed. You can recompile this dependency with `mix deps.compile comeonin` or update it with `mix deps.update comeonin`
** (Mix.Error) Could not compile Comeonin.
Please make sure that you are using Erlang / OTP version 17.0 or later
and that you have a C compiler installed.
Please follow the directions below for the operating system you are
using:

Windows: One option is to install a recent version of Visual Studio (the
free Community edition will be enough for this task). Then try running
`mix deps.compile comeonin` from the `Developer Command Prompt`.

Mac OS X: You need to have gcc and make installed. Try running the
commands `gcc --version` and / or `make --version`. If these programs
are not installed, you will be prompted to install them.

Linux: You need to have gcc and make installed. If you are using
Ubuntu or any other Debian-based system, install the package
`build essential`.

    mix.exs:24: Mix.Tasks.Compile.Comeonin.handle_error/0
    (elixir) lib/enum.ex:977: anonymous fn/3 in Enum.map/2
    (elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir) lib/enum.ex:977: Enum.map/2
    (mix) lib/mix/tasks/compile.all.ex:15: Mix.Tasks.Compile.All.run/1
    (mix) lib/mix/tasks/compile.ex:64: Mix.Tasks.Compile.run/1
    (mix) lib/mix/tasks/deps.compile.ex:105: anonymous fn/2 in Mix.Tasks.Deps.Compile.do_mix/1
    (mix) lib/mix/project.ex:196: Mix.Project.in_project/4

I checked and I have both gcc and make installed. Also the build-essential package.

mesosteros commented 9 years ago

Installing Visual Studio Express in order to get nmake and also installing directly erlang+otp allowed me to further progress. I'm now with the following error:

C:\Users\mesos_000\Desktop\elixir Projects\testeAddict>mix deps.compile comeonin
==> comeonin

Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

'priv\bcrypt_nif.dll' is up-to-date

Compiled lib/comeonin/config.ex
Compiled lib/comeonin/pbkdf2_base64.ex
Compiled lib/comeonin/bcrypt_base64.ex
Compiled lib/comeonin/tools.ex
Compiled lib/comeonin.ex
Compiled lib/comeonin/password.ex
Compiled lib/comeonin/pbkdf2.ex

== Compilation error on file lib/comeonin/bcrypt.ex ==
** (MatchError) no match of right hand side value: {:error, :on_load_failure}
    (stdlib) erl_eval.erl:669: :erl_eval.do_apply/6

could not compile dependency comeonin, mix compile failed. You can recompile this dependency with `mix deps.compile comeonin` or update it with `mix deps.update comeonin`

On my Ubuntu VM, installing erlang solved the issue.

trenpixster commented 9 years ago

@mesosteros hey! Sorry you're bumping into those issues :/ I don't currently have a Windows machine, have you tried asking for help to the comeonin guys? People at #elixir-lang at freenode are also extremely helpful.

trenpixster commented 9 years ago

@mesosteros updated the comeonin dependency, according to #52 it has more helpful build messages.

mesosteros commented 9 years ago

@trenpixster Tried it again to no avail. I keep getting the bcrypt error.

trenpixster commented 9 years ago

Just to be sure, did you update the addict reference on your mix.exs to 0.1.0? Also did you try running mix deps.clean --all and mix deps.get?

mesosteros commented 9 years ago

Yes. I tried it on a whole new project in fact. I've digged a bit further down and it seems this is related to a node-gyp issue which is a dependency of bcrypt which in turn is a dependency of comeonin. I'm trying a solution from the node-gyp project page and will let you know if it fixes this. (https://github.com/nodejs/node-gyp/issues/629)

mesosteros commented 9 years ago

No luck.

trenpixster commented 9 years ago

Have you considered using docker? :stuck_out_tongue:

mesosteros commented 9 years ago

No. Can't use docker for what I want... but I did manage to get through it... finally... I deleted the bcrypt.ex file from the /deps/comeonin/lib/comeonin/ folder... then mix phoenix.server ran smoothly.

trenpixster commented 9 years ago

Interesting hack, glad it worked! Kinda sucks that you'll have to remind to do that every time though. Closing this one for now, thanks for explaining the solution to your issue here :+1:

mesosteros commented 9 years ago

Finally managed to get through the issue without deleting bcrypt.ex. I created a symlink to my profile folder as it was non-ASCII standard (mesos_000 instead of mesos). I did it like so:

Run Command Prompt (as administrator):
cd C:\Users
mklink /d mesos mesos_000

Then run the Developer Command Prompt installed with Visual Studio 2015 (from the start menu -> applications), also as administrator, going to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\

and running the command vcvarsall.bat amd64

Finally, I created a completely new phoenix project in my elixir projects folder, added

{:addict, ">= 0.1.0"}
mix deps.get
mix deps.compile comeonin

and pronto.

trenpixster commented 9 years ago

Awesome! It'd be cool to also add that information to the comeonin project :+1: