尝试编译argon2_elixir时nmake失败

时间:2019-04-10 15:22:00

标签: elixir dependency-management nmake mix

我正在尝试将argon2_elixir添加到我的phoenix项目中,但是在编译时出现此错误:

mix compile
==> argon2_elixir

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

makefile(34) : fatal error U1000: syntax error : ')' missing in macro invocation
Stop.
could not compile dependency :argon2_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile argon2_elixir", update it with "mix deps.update argon2_elixir" or clean it with "mix deps.clean argon2_elixir"
==> chatter
** (Mix) Could not compile with "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe" (exit status: 2).
One option is to install a recent version of
[Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools)
either manually or using [Chocolatey](https://chocolatey.org/) -
`choco install VisualCppBuildTools`.

After installing Visual C++ Build Tools, look in the "Program Files (x86)"
directory and search for "Microsoft Visual Studio". Note down the full path
of the folder with the highest version number. Open the "run" command and
type in the following command (make sure that the path and version number
are correct):

    cmd /K "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

This should open up a command prompt with the necessary environment variables
set, and from which you will be able to run the "mix compile", "mix deps.compile",
and "mix test" commands.

在发生此错误之前,它先前曾提到如何找不到nmake.exe并将其设置为MAKE系统变量。因此,我进入了环境变量并将路径设置为C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe

如果使用以下命令cmd /K "C:\..." amd64打开cmd / powershell,则必须cd回到phoenix项目。运行mix compile / mix deps.compile argon2_elixir后,它给了我同样的错误。

我注意到有一个closed github issue,但没有解决方案。

这是我的mix.ex文件

defmodule Chatter.MixProject do
  use Mix.Project

  def project do
    [
      app: :chatter,
      version: "0.1.0",
      elixir: "~> 1.5",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:phoenix, :gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Chatter.Application, []},
      extra_applications: [:logger, :runtime_tools, :phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext,
      :phoenix_ecto, :postgrex, :comeonin ]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.4.1"},
      {:phoenix_pubsub, "~> 1.1"},
      {:phoenix_ecto, "~> 4.0"},
      {:ecto_sql, "~> 3.0"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:comeonin, "~> 5.1.1"},
      {:argon2_elixir, "~> 2.0"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to create, migrate and run the seeds file at once:
  #
  #     $ mix ecto.setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate", "test"]
    ]
  end
end

1 个答案:

答案 0 :(得分:1)

{ "timestamp": "2019-04-11T15:03:51.274Z", "level": "INFO", "thread": "main", "mdc": { "traceId": "082f65c7-6751-4ca0-bd30-e6f0230d0fd8", "eventType": "CALL_SUCCESSFUL", "occuredOn": "2019-04-11T15:03:51.269Z", "AWSRequestId": "d0894316-07f4-47b9-9e7a-55384fb579f2" }, "logger": "jsonLogger", "message": "Call to external successful, "context": "default" } 2019-04-11T15:03:51.274Z d0894316-07f4-47b9-9e7a-55384fb579f2 INFO jsonLogger - Call to external successful 中第34行出现错误。在Windows上应该使用Makefile而不是Makefile.win,但是在这种情况下则不会。

事实证明,这是Makefile的“功能”。如果要使用的make可执行文件为elixir_make,则使用参数nmake,否则不指定要使用哪个makefile,而/F Makefile.win可能会退回到使用{{1} }。发生here

但是由于您将nmake环境变量设置为Makefile,因此它不再等于MAKE,因此使用C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe代替了{{1 }}-您会收到错误消息。

我建议两件事:

  • 更改nmake以包括Makefile所在的目录,而不是设置Makefile.win环境变量。
  • Report a bug in elixir_make。它应该检查MAKE指定的可执行文件是否具有文件名PATHnmake.exe,而与目录无关,而不是简单地与字符串MAKE进行比较。