# Code loading on remote test nodes using \`peer\`

**URL:** <https://erlangforums.com/t/code-loading-on-remote-test-nodes-using-peer/1802>\
**Category:** Questions / Help\
**Tags:** common\_test, peer\
**Created:** [August 31, 2022, 3:48pm UTC](https://erlangforums.com/t/code-loading-on-remote-test-nodes-using-peer/1802 "2022-08-31T15:48:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmin](https://erlangforums.com/user_avatar/erlangforums.com/mmin/32/2193_2.png) [@mmin](https://erlangforums.com/u/mmin)\
**Post date:** [August 31, 2022, 3:48pm UTC](https://erlangforums.com/t/code-loading-on-remote-test-nodes-using-peer/1802/1 "2022-08-31T15:48:02Z")

</div>

Lets say that we want to test application `app1` that has dependencies to `dep1` and `dep2`. How do I spawn slaves that has those 3 applications loaded or at least path to binaries in their code path? I want to avoid manually adding path for every app and loading it via `erpc`.

---

<div class="post-metadata">

**Author:** ![max-au](https://erlangforums.com/user_avatar/erlangforums.com/max-au/32/1627_2.png) [@max-au](https://erlangforums.com/u/max-au)\
**Post date:** [August 31, 2022, 5:02pm UTC](https://erlangforums.com/t/code-loading-on-remote-test-nodes-using-peer/1802/2 "2022-08-31T17:02:34Z")

</div>

There are multiple options (although I think adding code path via RPC is the easiest):

1. Work with releases. There is code example [in the documentation](https://www.erlang.org/doc/man/peer.html#example) that works with Docker - by building the release (see “build\_release” function definition).

```erlang
Release = {release, {"lambda", "1.0.0"},
              {erts, erlang:system_info(version)},
              [{App, begin {ok, Vsn} = application:get_key(App, vsn), Vsn end}
                  || App <- [kernel, stdlib, sasl]]},
          ok = file:write_file(RelFile, list_to_binary(lists:flatten(
              io_lib:format("~tp.", [Release])))),
          RelFileNoExt = filename:join(Dir, "lambda"),

          %% create boot script
          {ok, systools_make, []} = systools:make_script(RelFileNoExt,
              [silent, {outdir, Dir}]),

```

1. Pass paths in the `?CT_PEER` startup arguments:

```erlang
Paths = lists:append([["-pa", code:lilb_dir(App)] || App <- [app1, app2, app3]),
{ok, Peer, Node} = ?CT_PEER(Paths)

```

1. Load code paths in bulk via rpc: `erpc:call(code, add_paths, [code:get_path()])`

You may also explore `LIB_DIR` environment variable, e.g. `?CT_PEER(["-env", "LIB_DIR", RootFolder])` - I haven’t tried it but it may also work.

---

<div class="post-metadata">

**Author:** ![mmin](https://erlangforums.com/user_avatar/erlangforums.com/mmin/32/2193_2.png) [@mmin](https://erlangforums.com/u/mmin)\
**Post date:** [September 1, 2022, 11:54am UTC](https://erlangforums.com/t/code-loading-on-remote-test-nodes-using-peer/1802/3 "2022-09-01T11:54:50Z")

</div>

Yes, `code:lib_dir/1` was something I was looking for, thank You! If I’ll make it with LIB\_DIR I’ll post it here 😃
