elixir - 在 Elixir 中使用 Erlang 库

标签 elixir

我在尝试在 Elixir 项目中使用 Erlang 库时遇到了一个小问题。
有问题的图书馆是 erl8583用于 ISO-8583 消息打包和解包。

我找到了 erl8583 的 github 存储库,并调整了我的 mix.exs到以下几点:

defmodule Iso.Mixfile do
  use Mix.Project

  def project do
    [app: :iso,
     version: "0.0.1",
     elixir: "~> 1.0",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps]
  end

  def application do
    [applications: [:logger]]
  end

  defp deps do
    [{:erl8583, github: "mgwidmann/erl8583"}]
  end
end

当我跑 mix deps.getmix deps.compile ,运行流畅。

然后,我尝试使用 iex -S mix 开始 IEx session 。 ,并得到以下错误:
Unchecked dependencies for environment dev:
* erl8583 (git://github.com/mgwidmann/erl8583.git)
  could not find an app file at _build/dev/lib/erl8583/ebin/erl8583.app. This may happen if the dependency was not yet compiled, or you specified the wrong application name in your deps, or the dependency indeed has no            app file (then you can pass app: false as option)
** (Mix) Can't continue due to errors on dependencies

上面写着 could not find an app file at _build/dev/lib/erl8583/ebin/erl8583.app .据我了解,mix 应该刚刚从 deps/erl8583/src 中获取了该文件。并包含在那里(该文件存在,我检查过)。

我试图从 deps 手动复制文件至 _build但没有成功。我做错了什么?

最佳答案

erl8583应用程序来源 .app文件名错误。一个 .app文件通常位于 ebin Erlang 应用程序的目录;如果它是用于生成 .app 的源文件文件,它应该命名为 .app.src反而。如果您重命名它,它将起作用,如下面的 shell session 所示:

$ mix deps.get
* Getting erl8583 (https://github.com/mgwidmann/erl8583.git)
Cloning into '/private/tmp/m/deps/erl8583'...
remote: Counting objects: 3468, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 3468 (delta 1), reused 0 (delta 0), pack-reused 3464
Receiving objects: 100% (3468/3468), 1002.71 KiB | 618.00 KiB/s, done.
Resolving deltas: 100% (2640/2640), done.
Checking connectivity... done.
$ mv ./deps/erl8583/src/erl8583.app ./deps/erl8583/src/erl8583.app.src
$ mix deps.compile
==> erl8583 (compile)
Compiled src/erl8583_message_helpers.erl
Compiled src/erl8583_message.erl
Compiled src/erl8583_marshaller_xml.erl
Compiled src/erl8583_marshaller_ebcdic.erl
Compiled src/erl8583_marshaller_json.erl
Compiled src/erl8583_marshaller_binary.erl
Compiled src/erl8583_marshaller_ascii.erl
Compiled src/erl8583_fields_2003.erl
Compiled src/erl8583_fields_1993.erl
Compiled src/erl8583_fields.erl
Compiled src/erl8583_marshaller.erl
src/erl8583_convert.erl:133: Warning: variable 'AsciiHex' is unused
src/erl8583_convert.erl:136: Warning: variable 'IntValue' is unused
Compiled src/erl8583_convert.erl
$ iex -S mix
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]

Generated iso app
Interactive Elixir (1.1.0-rc.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

关于elixir - 在 Elixir 中使用 Erlang 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32662329/

相关文章:

elixir - 如何使用 Mix CLI 安装早期版本的 Phoenix?

testing - 断言中未使用的警告变量

process - 当不再引用其 PID 时,Elixir 进程是否会终止?

Python Django 相当于 Elixir Ecto 中的预加载

elixir - 使用带有 iex -S mix phoenix.server 的 webpack 时如何摆脱 ^H?

function - 更新匿名函数 Elixir 中的命名函数变量

dictionary - 如何检查 key 是否存在于 Elixir 的深度嵌套 Map 中

elixir - 手动添加 gettext 翻译键

javascript - 如何在 Firefox 扩展中使用模块?

Elixir/Phoenix 限制参数,如 Rails 强参数