rebar3 无法加载编译文件

问题描述

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

我使用了 rebar3 new app rabbit。我在 rabbit_app.erl rabbit_sup.erl and rabbit.app.src 目录中有 hello_world.erl一个名为 src/ 的新定义文件。我运行 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
 

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

解决方法

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