在Windows上添加十六进制包依赖项错误在Mac上不会出现

时间:2015-07-28 11:45:49

标签: compiler-errors packages elixir phoenix-framework

我尝试在我的凤凰计划中安装addict包但是我收到了错误。 我在同事的Mac上尝试了完全相同的过程,并且他没有得到错误,而我在Windows上做错了。 错误来自comeonin依赖。我也曾在昨天发布的Phoenix 0.14和0.15更新中尝试过它。

重新创建的步骤:

  1. 创建一个新项目并运行它

    $ mix phoenix.new testAddict
    $ cd testAddict
    $ mix ecto.create
    $ mix phoenix.server
    
  2. 在mix.exs中添加addict:

    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
    
  3. 编译依赖项:

    $ mix deps.get

  4. 结果:

    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. 再次运行Phoenix项目:

      $ mix phoenix.server

    2. 结果(这是错误):

      ==> 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. 尝试建议:

        $ mix deps.compile comeonin

      2. 结果:

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

        结果:与上述错误相同。

        $ mix deps.update comeonin
        

        结果:

        ==> 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
        

        修改 在JoséValim的建议之后,我安装了Visual Studio Express以获得nmake。我还必须从erlang站点安装更新版本的erlang + otp。 最后,我现在得到一个不同但仍然相关的错误:

        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`
        

        另外,在我的Ubuntu VM上安装erlang完全解决了问题。问题仍然存在于我的Windows 8.1中。

2 个答案:

答案 0 :(得分:2)

解决了comeonin依赖性错误的说明已经更新,我设法通过他们所说的来解决这个问题:

打开Visual Studio的开发人员命令提示符(在Windows 8,8.1和10中,它位于Visual Studio应用程序菜单下)。

$ cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
$ vcvarsall amd64

现在应该编译comeonin依赖。

答案 1 :(得分:0)

您需要安装nmake。引用另一个SO回答:

  

NMake是Microsoft构建C ++项目的构建工具的一部分。您可以通过下载Visual C++ Express获得nmake以及MSVC ++编译器。 Visual C ++ Express在Windows 7上运行完美。

来源:https://superuser.com/questions/146577/where-do-i-find-nmake-for-windows-7