Something like Mix.install, for Erlang?

I’m writing some Erlang scripts/snippets, and they require some extra dependencies.

If this were Elixir, I’d stick Mix.install([blah]) at the top of my script and be done. But this is Erlang.

What are people doing to deal with this in Erlang scripts? Is there some way I can use rebar3 to install my deps somewhere and then point the ERL_LIBS environment variable at that place? That’d be enough for my immediate use case.

I use few escripts to run benchmarks in regular rebar3 umbrella projects.

Here’s my workflow (assuming one script per profile):

  1. Place escript in test/
  2. Add escript config to rebar.config:
  {test,
      [{deps, [my_escript_dep]}
      {escript_incl_apps, [main_app, my_escript_dep]},
      {escript_main_app, main_app},
      {escript_name, my_escript},
      %% makes escript visible
      {escript_emu_args, "%%! +sbtu +A1 -pa _build/test/lib/main_app/test/ \n"},
      {post_hooks,
          %% not necessary - just runs it after building is finished
          [{escriptize, "$REBAR_BUILD_DIR/bin/my_escript"}]}
  	]}
  1. run rebar3 as test escriptize

You can use different profile and you can also use -include_lib in scripts if you needed.

It’s not similar to Mix.install but hope it helps.

For the moment, I’m putting the extra dependencies in another rebar profile, and then using rebar3 as examples do auto (for the snippets).

It’ll do for now, but it’s kinda inflexible, though.

Kinda hoping for a rebar3 install, like mix archive.install (except maybe without the archive bit). Probably also needs a rebar3 install –prefix or similar.