【问题标题】:Addict hex package dependencies error on Windows that does not occur on MacMac 上不会发生的 Windows 上的 Addict 十六进制包依赖项错误
【发布时间】:2015-10-18 22:53:40
【问题描述】:

我尝试在我的 Phoenix 项目中安装 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

结果:

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

结果(这里是错误):

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

结果:

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 中。

【问题讨论】:

    标签: compiler-errors packages elixir phoenix-framework


    【解决方案1】:

    解决 comeonin 依赖错误的说明已更新,我按照他们所说的方法解决了这个问题:

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

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

    comeonin 依赖项现在应该可以编译了。

    【讨论】:

    • 我使用 Visual Studio Express 2015 完成了此操作。我必须更改我的安装以确保安装了 C++ 工具。本例中的路径是C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
    【解决方案2】:

    您需要安装 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

    【讨论】:

    • 我安装了 Visual Studio Express 和 Ultimate,但它没有工作。我使用的是 Windows 8.1。
    • 如果你启动一个命令并输入“nmake”,你会得到什么?
    • C:\Users\mesos_000>nmake 'nmake' is not recognized as an internal or external command, operable program or batch file.
    • 我刚刚在 /VC/bin/nmake.exe 下的 Visual Studio 文件夹中找到它,但运行它并没有设置它。
    • 我收到NMAKE : fatal error U1064: MAKEFILE not found and no target specified Stop.
    猜你喜欢
    • 2016-12-21
    • 2019-04-21
    • 2015-07-04
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    • 2014-10-12
    • 1970-01-01
    • 2015-06-11
    相关资源
    最近更新 更多