尝试编译 argon2_elixir 时,nmake 失败

Posted

技术标签:

【中文标题】尝试编译 argon2_elixir 时,nmake 失败【英文标题】:nmake fails when attempting to compile argon2_elixir 【发布时间】:2019-04-10 15:21:59 【问题描述】:

我正在尝试将 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/powershell cmd /K "C:\..." amd64 我必须 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

【问题讨论】:

这是一个 argon2_elixir 问题,因为如果我删除了这种依赖关系,那么我可以正常运行 comeonin @Adam 感谢编辑提示 :) 所以它在 makefile 的第 34 行发现了一个错误 - 但 argon2_elixir 也有 a Makefile.win file。我想问题是 something 选择运行 Makefile 而不是 Makefile.win 【参考方案1】:

Makefile 的第 34 行出现错误。它应该在 Windows 上使用 Makefile.win 而不是 Makefile,但在这种情况下它没有。

原来这是elixir_make的一个“功能”。如果要使用的make 可执行文件是nmake,它使用参数/F Makefile.win,否则它不指定使用哪个makefile,并且nmake 可能会回退到使用Makefile。发生这种情况here。

但是由于您将MAKE 环境变量设置为C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe,因此它不再等于nmake,因此使用Makefile 而不是Makefile.win - 你会得到一个错误。

我建议两件事:

不要设置MAKE 环境变量,而是更改PATH 以包含nmake.exe 所在的目录。 Report a bug in elixir_make。它可能应该检查MAKE 指定的可执行文件是否具有文件名nmakenmake.exe 而不管目录,而不是简单地与字符串"nmake" 进行比较。

【讨论】:

只是指出,遇到Makefile.win的任何人的原因是,您要么在目录中有makefile,如果是这样,只需创建另一个名为Makefile.win的文件没有任何实际的env If 语句等,否则会出错。它会自动完成编译...大声笑

以上是关于尝试编译 argon2_elixir 时,nmake 失败的主要内容,如果未能解决你的问题,请参考以下文章

尝试编译二叉树程序时出错

尝试使用Maven编译谷歌编译器时出错

尝试编译“while”语句时的“unreachable statement”

尝试编译 MEX 文件时缺少 libkernel32

当我尝试导入猫鼬模型时,Webpack 无法编译

尝试编译 Yolo 时,我收到 package not found 错误