简体   繁体   English

如何方便加载Erlang模块

[英]How to load Erlang modules conveniently

I am asking fellow Erlang developers how do they load specific modules in the erlang shell.我在问Erlang开发人员如何在erlang shell中加载特定模块。 I find it very cumbersome to:我觉得很麻烦:

  • open erlang shell打开erlang shell
  • copy path of module -> /path/.../ to the shell将模块的路径 -> /path/.../到 shell
  • change all backslashes from path to \path\将所有反斜杠从路径更改为\path\
  • run c(editedPath)运行c(editedPath)

And this only for one module.这仅适用于一个模块。 Can't erlang just be opened in a particular folder and load everything that is there? erlang 不能在特定文件夹中打开并加载那里的所有内容吗? Or can't i move to target folder and from that terminal start erlang shell and load modules?或者我不能移动到目标文件夹并从该终端启动 erlang shell 并加载模块?

PS I am using VS Code and it would be really helpful to just open the integrated terminal in target folder and start loading the modules on that relative path. PS我正在使用VS Code,只需打开目标文件夹中的集成终端并开始在该相对路径上加载模块会非常有帮助。

change all backslashes from path to `\path\将所有反斜杠从 path 更改为 `\path\

Why would anyone do that?为什么会有人这样做?

Or can't i move to target folder and from that terminal start erlang shell and load modules?或者我不能移动到目标文件夹并从该终端启动 erlang shell 并加载模块?

Yes.是的。 That's what I do for messing around while learning erlang.这就是我在学习 erlang 时搞砸的。 But for larger projects, there's rebar3 , which is erlang's package manager.但是对于较大的项目,有rebar3 ,它是 erlang 的 package 经理。 rebar3 projects employ a specific directory structure for your own source code, and then rebar3 will fetch and compile imported packages as well as your source code with a single command. rebar3项目为您自己的源代码使用特定的目录结构,然后 rebar3 将使用单个命令获取和编译导入的包以及您的源代码。

Also, see the flags -pa and -pz for the erl command .此外,请参阅erl 命令的标志-pa-pz

You need to read up a bit about the code server and how it handles the code path - see http://erlang.org/doc/man/code.html您需要阅读一些关于代码服务器以及它如何处理代码路径的信息 - 请参阅http://erlang.org/doc/man/code.html

Set up the code path (with absolute paths only) so that it points to one or more of your "ebin" directories containing.beam files - or set the ERL_LIBS environment variable to point out the parent directory of your Erlang apps, so that they get automatically added to the path.设置代码路径(仅限绝对路径),使其指向一个或多个包含 .beam 文件的“ebin”目录 - 或设置 ERL_LIBS 环境变量以指向 Erlang 应用程序的父目录,以便它们自动添加到路径中。

Do not add "."不要加“.” to the path except if you're just playing around.到路径,除非你只是在玩耍。 For a non-toy application, you should generally never rely on the current working directory of the Erlang VM (since Erlang runs a number of independent processes, the idea of a global current directory is pretty shaky anyway).对于非玩具应用程序,您通常不应该依赖 Erlang VM 的当前工作目录(因为 Erlang 运行许多独立的进程,因此全局当前目录的想法无论如何都非常不稳定)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM