【问题标题】:rebar3 can't load compiled filesrebar3 无法加载编译文件
【发布时间】:2021-08-20 18:29:58
【问题描述】:

我已经使用 reabr3 创建了一个应用程序来练习 RabbitMQ,但是 rebar3 无法将我在src 文件夹中创建的附加文件加载到 erlang shell。

我使用了rebar3 new app rabbit。我在src/ 目录中有rabbit_app.erl rabbit_sup.erl and rabbit.app.src 和一个名为hello_world.erl 的新定义文件。我运行rebar3 compile 来编译并获取依赖项。

然后运行rebar3 shell 以测试hello_world.erl 中的功能。 hello_world.beam 无法加载,所以我必须在 erlang shell 中手动使用 c(hello_world)。有点不方便。

任何帮助将不胜感激。这是rebar3 compilerebar3 shell 的控制台输出。

$ rebar3 compile
===> Verifying dependencies...
===> Fetching amqp_client v3.8.14
===> Fetching rabbit_common v3.8.7
===> Fetching credentials_obfuscation v2.2.0
===> Fetching jsx v2.11.0
===> Fetching lager v3.8.0
===> Fetching ranch v1.7.1
===> Fetching recon v2.5.1
===> Fetching goldrush v0.1.9
===> Analyzing applications...
===> Compiling credentials_obfuscation
===> Compiling goldrush
===> Compiling jsx
===> Compiling lager
===> Compiling ranch
===> Compiling recon
===> Compiling rabbit_common
===> Compiling amqp_client
===> Analyzing applications...
===> Compiling rabbit

$ rebar3 shell
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling rabbit
Erlang/OTP 22 [erts-10.7.2.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe]

Eshell V10.7.2.1  (abort with ^G)
1> ===> Booted xmerl
===> Booted compiler
===> Booted sasl
===> Booted syntax_tools
===> Booted tools
===> Booted goldrush
===> Booted lager
===> Booted jsx
===> Booted ranch
===> Booted recon
===> Booted credentials_obfuscation
===> Booted rabbit_common
===> Booted amqp_client
===> Booted rabbit
 

[更新] 我发现新添加的文件已加载,但这些文件的自动完成功能不起作用。我必须第一次使用整个命令。

【问题讨论】:

  • 代替 c(hello_world).,尝试​​ r3:compile().
  • 它现在有效。谢谢!你能解释一下这个命令背后的内容吗?我看到它还编译了我的rabbit 应用程序。它是否也将梁文件加载到 Erlang shell?
  • 你应该在这里找到所有这些信息和更多信息:ferd.ca/rebar3-shell.html

标签: rabbitmq erlang elixir rebar3


【解决方案1】:

rebar3.beam 文件组织在src 目录之外的目录中。当您发出命令c(hello_world) 时,.beam 文件将放置在当前目录中。显然,您在当前目录是src/ 目录时发出rebar3 命令,这不是rebar3 的处理方式。您需要在rabbit/ 目录中,即app 的顶级目录中,当您发出rebar3 命令时,如rebar3 compilerebar3 shell

【讨论】:

  • 是的,当我发出rebar3 compile and rebar3 shell 时,我在rabbit/ 目录中。我可以看到_build/default/lib/rabbit/ebin/hello_world.beam。但我无法在 shell 中调用 hello_world 模块。
  • @tandathuynh148,显示您的命令行命令、shell 命令和输出。我并不是说你应该描述你做了什么,而是发布实际的命令和输出,从创建应用程序开始。
  • 非常感谢。您可以在此处找到命令的输出:imgur.com/Y8rZOMZimgur.com/aSFrFN2
  • @tandathuynh148,您能否检查一下hello_world 是否列在modules 列表中的_build/default/lib/rabbit/ebin/rabbit.app 文件中?还有你用的是什么版本的rebar3
  • @tandathuynh148,对不起,这不是在 stackoverflow 上做事的方式。复制并粘贴您的命令和输出并将它们发布在问题的底部。链接到图片是一种糟糕的形式——也不要发布图片。
猜你喜欢
  • 2019-02-07
  • 1970-01-01
  • 1970-01-01
  • 2021-10-29
  • 1970-01-01
  • 1970-01-01
  • 2021-01-25
  • 2013-11-24
  • 2012-09-04
相关资源
最近更新 更多