---
name: "erl_prim_loader"
section: "3erl"
platform: "linux"
package: "erlang-manpages"
version: "1:25.2.3+dfsg-1+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/erl_prim_loader"
---

# erl\_prim\_loader(3erl)

Low-level Erlang loader.

## NAME

erl\_prim\_loader - Low-level Erlang loader.

## DESCRIPTION

This module is used to load all Erlang modules into the system. The start script is also fetched with this low-level loader.

*erl\_prim\_loader* knows about the environment and how to fetch modules.

Command-line flag *-loader Loader* can be used to choose the method used by *erl\_prim\_loader*. Two *Loader* methods are supported by the Erlang runtime system: *efile* and *inet*.

## EXPORTS

```
get_file(Filename) -> {ok, Bin, FullName} | error
```

Types:

Filename = atom() \| string()\
 Bin = binary()\
 FullName = string()\

Fetches a file using the low-level loader. *Filename* is either an absolute filename or only the name of the file, for example, *"lists.beam"*. If an internal path is set to the loader, this path is used to find the file. *FullName* is the complete name of the fetched file. *Bin* is the contents of the file as a binary.

*Filename* can also be a file in an archive, for example, *$OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin/mnesia.beam*. For information about archive files, see *[code(3erl)](/code/3erl.md)*.

```
get_path() -> {ok, Path}
```

Types:

Path = \[Dir :: string()\]\

Gets the path set in the loader. The path is set by the *[init(3erl)](/init/3erl.md)* process according to information found in the start script.

```
list_dir(Dir) -> {ok, Filenames} | error
```

Types:

Dir = string()\
 Filenames = \[Filename :: string()\]\

Lists all the files in a directory. Returns *{ok, Filenames}* if successful, otherwise *error*. *Filenames* is a list of the names of all the files in the directory. The names are not sorted.

*Dir* can also be a directory in an archive, for example, *$OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin*. For information about archive files, see *[code(3erl)](/code/3erl.md)*.

```
read_file_info(Filename) -> {ok, FileInfo} | error
```

Types:

Filename = string()\
 FileInfo = file:file\_info()\

Retrieves information about a file. Returns *{ok, FileInfo}* if successful, otherwise *error*. *FileInfo* is a record *file\_info*, defined in the Kernel include file *file.hrl*. Include the following directive in the module from which the function is called:

```
-include_lib("kernel/include/file.hrl").
```

For more information about the record *file\_info*, see *[file(3erl)](/file/3erl.md)*.

*Filename* can also be a file in an archive, for example, *$OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin/mnesia*. For information about archive files, see *[code(3erl)](/code/3erl.md)*.

```
read_link_info(Filename) -> {ok, FileInfo} | error
```

Types:

Filename = string()\
 FileInfo = file:file\_info()\

Works like *read\_file\_info/1* except that if *Filename* is a symbolic link, information about the link is returned in the *file\_info* record and the *type* field of the record is set to *symlink*.

If *Filename* is not a symbolic link, this function returns exactly the same result as *read\_file\_info/1*. On platforms that do not support symbolic links, this function is always equivalent to *read\_file\_info/1*.

```
set_path(Path) -> ok
```

Types:

Path = \[Dir :: string()\]\

Sets the path of the loader if *[init(3erl)](/init/3erl.md)* interprets a *path* command in the start script.

## COMMAND-LINE FLAGS

The *erl\_prim\_loader* module interprets the following command-line flags:

- ***-loader Loader*:**

  Specifies the name of the loader used by *erl\_prim\_loader*. *Loader* can be *efile* (use the local file system) or *inet* (load using the *boot\_server* on another Erlang node).

  If flag *-loader* is omitted, it defaults to *efile*.

- ***-loader\_debug*:**

  Makes the *efile* loader write some debug information, such as the reason for failures, while it handles files.

- ***-hosts Hosts*:**

  Specifies which other Erlang nodes the *inet* loader can use. This flag is mandatory if flag *-loader inet* is present. On each host, there must be on Erlang node with the *[erl\_boot\_server(3erl)](/erl_boot_server/3erl.md)*, which handles the load requests. *Hosts* is a list of IP addresses (hostnames are not acceptable).

- ***-setcookie Cookie*:**

  Specifies the cookie of the Erlang runtime system. This flag is mandatory if flag *-loader inet* is present.

## SEE ALSO

*[init(3erl)](/init/3erl.md)*, *[erl\_boot\_server(3erl)](/erl_boot_server/3erl.md)*
