gpt4 book ai didi

elixir - 如何重新编译 Elixir 项目并从 iex 中重新加载它?

转载 作者:行者123 更新时间:2023-12-03 05:56:00 24 4
gpt4 key购买 nike

我目前正在通过 elixir-lang 网站上的 OTP 和混合教程来学习 Elixir,但我无法找到如何从 shell 内重新编译和重新加载项目。

在 Erlang 中,我会执行 make:all([load]) ,它将编译并加载发生的任何更改。然而,在 iex 中总是显示 :up_to_date,这确实有意义,因为 Elixir 使用 mix 来满足其编译需求。

我在 iex 中找不到任何等效项。

最佳答案

您可以使用IEx.Helpers.recompile/0功能。

Recompiles the current Mix application.

This helper only works when IEx is started with a Mix project, for example, iex -S mix. Before compiling the code, it will stop the current application, and start it again afterwards. Stopping applications are required so processes in the supervision tree won't crash when code is upgraded multiple times without going through the proper hot-code swapping mechanism.

Changes to mix.exs or configuration files won't be picked up by this helper, only changes to sources. Restarting the shell and Mix is required in such cases.

If you want to reload a single module, consider using r ModuleName instead.

NOTE: This feature is experimental and may be removed in upcoming releases.

来自https://github.com/elixir-lang/elixir/blob/v1.2.4/lib/iex/lib/iex/helpers.ex#L56-L93

关于elixir - 如何重新编译 Elixir 项目并从 iex 中重新加载它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36490089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com