[erlang-questions] Re: [erlang-questions 71] Erlang release generation

Håkan Mattsson <>
Mon Mar 28 17:10:25 CEST 2011


On Mon, Mar 28, 2011 at 8:07 AM, Sam Bobroff <> wrote:
> Hi Erlangers,
>
> I've been trying to work out how to "properly" build Erlang releases (on
> a Linux system, to be deployed on another Linux system), and I'm getting
> nowhere fast so I'm hoping someone here will have some useful pointers
> or hints to help me out. I'm using Erlang R14B, but I assume the
> problems I'm having are to do with understanding, rather than bugs so
> the version probably doesn't matter much ;-)
>
> For context, I've read a lot of the online Erlang documentation
> including the sections on systools, reltool, sys, rel (and I've read the
> Rebar documentation as well, I'll get to that later) and I'm familiar
> with setting up OTP applications but this issue is confusing me more and
> more: there doesn't seem to be any kind of overview that tells me how
> the various pieces fit together or what I'm supposed to do. Is there
> some standard document I'm missing?

No, better documentation is needed.

> "All" I want to do is go from a set of Erlang source, representing one
> or more applications (presumably in a set of src and ebin dirs), to an
> installed Erlang system that will start those applications. (Which I'm
> obviously intending to package up for distribution but that's a separate
> issue.)
>
> I realize I'm rambling so I'll try to phrase some specific questions:
>
> Is reltool:create_target() the correct way to build a release?

Yes.

> If so, how do I get reltool:create_target() to include my apps? I've
> tried using lib_dirs and -pa in various combinations but I always get
> "Release NAME uses non existing application APP". I haven't yet tried
> installing my application directly to the system Erlang
> (/usr/lib/erlang/lib in my case) because the reltool doc clearly states
> that "Applications may also be located outside root_dir ...". Does this
> just not work? I'm not keen on installing my apps into the system Erlang
> (as root) just so that I can build a release!

You should be able to use lib_dirs to refer to your apps if they reside
outside root_dir. But do observe that each lib_dir sould refer to a
directory containing one sub directory for each app. It is the same
directory structure as $ERL_TOP/lib/erlang/lib.

> I've discovered that if I use reltool:create_target() to build a release
> (and don't include any custom apps, so it works), I can't then use that
> release as a development environment because running reltools fails on
> all applications, even kernel. It seems to be that reltool doesn't
> understand that things have been packaged up as .ez files because
> manually extracting them all allows it to succeed. Is there a way to get
> reltool to build a release that isn't zipped up, or to understand the
> zipped files?

Reltool should cope with sources in .ez files. I have not tried this for a
long time, so it may be broken.

> Should I instead be following the "target_system" module that's in the
> "Creating a First Target System" section of the documentation? It seems
> pretty odd to cut and paste a big chunk of example code out of the docs
> to do a basic task... and it's also very slow because of the way it tars
> everything up just to untar it again. This is, however, the only way
> I've managed to get a release of my own app actually built.

This should not be necessary. Reltool should be able to do that for you.

> Should I just build .rel files by hand and basically re-implement
> target_system.erl (but more the way I want it to work)?

This should not be necessary. Reltool should be able to do that for you.

It is hard to tell what it is that is causing your Reltool problems. It seems
like you have understood how it is intended to work (despite the brief
documentation).

In order to dig deeper I would need see your indata to reltool:create_target()
and look at the directory structure under your lib_dirs. Another possibility is
that you take a look at how this little escript (search for --install) creates a
target system with one app that is located outside root_dir:

  https://github.com/hawk/eflex/blob/master/bin/eflex

You can download the app, build it and try to install it as a standalone tool.
If that works it is perhaps possible to figure out what it is that differs with
your original setup. Please, let me know how it works out for you.

/Håkan



More information about the erlang-questions mailing list