简体   繁体   中英

How to load Erlang modules conveniently

I am asking fellow Erlang developers how do they load specific modules in the erlang shell. I find it very cumbersome to:

  • open erlang shell
  • copy path of module -> /path/.../ to the shell
  • change all backslashes from path to \path\
  • run c(editedPath)

And this only for one module. Can't erlang just be opened in a particular folder and load everything that is there? Or can't i move to target folder and from that terminal start erlang shell and load modules?

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.

change all backslashes from path to `\path\

Why would anyone do that?

Or can't i move to target folder and from that terminal start erlang shell and load modules?

Yes. That's what I do for messing around while learning erlang. But for larger projects, there's rebar3 , which is erlang's package manager. 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.

Also, see the flags -pa and -pz for the erl command .

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

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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