0

When i generate release application with rebar and try start it with key console i have error

{"init terminating in do_boot",{'cannot load',pgsql,get_file}}.

In all files app.src and reltool.config i have epgsql app added.

app.src:

{application, leasing,
 [
  {description, ""},
  {vsn, "1"},
  {registered, []},
  {applications, [
              kernel,
              stdlib,
              crypto,
              ssl,
              public_key,
              epgsql,
              amqp_client,
              rabbit_common
            ]},
{mod, { leasing_app, []}},
{env, []}
]}.

reltool.config

{sys, [
   {lib_dirs, ["../deps", "../apps"]},
   {erts, [{mod_cond, derived}, {app_file, strip}]},
   {app_file, strip},
   {rel, "leasingnode", "1",
    [
     kernel,
     stdlib,
     sasl,
     crypto,
     ssl,
     public_key,
     epgsql,
     amqp_client,
     rabbit_common,
     leasing
    ]},
   {rel, "start_clean", "",
    [
     kernel,
     stdlib
    ]},
   {boot_rel, "leasingnode"},
   {profile, embedded},
   {incl_cond, exclude},
   {excl_archive_filters, [".*"]}, %% Do not archive built libs
   {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)",
                       "^erts.*/(doc|info|include|lib|man|src)"]},
   {excl_app_filters, ["\.gitignore"]},
   {app, sasl,   [{incl_cond, include}]},
   {app, stdlib, [{incl_cond, include}]},
   {app, kernel, [{incl_cond, include}]},
   {app, crypto, [{incl_cond, include}]},
   {app, ssl, [{incl_cond, include}]},
   {app, public_key, [{incl_cond, include}]},
   {app, epgsql, [{incl_cond, include}]},
   {app, amqp_client, [{incl_cond, include}]},
   {app, rabbit_common, [{incl_cond, include}]},
   {app, leasing, [{incl_cond, include}]}

  ]}.

{target_dir, "leasingnode"}.

{overlay, [
       {mkdir, "log/sasl"},
       {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
       {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"},
       {copy, "files/leasingnode", "bin/leasingnode"},
       {copy, "files/leasingnode.cmd", "bin/leasingnode.cmd"},
       {copy, "files/start_erl.cmd", "bin/start_erl.cmd"},
       {copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"},
       {copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},
       {copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"}
      ]}.

when i start it from erl shell all ok, but when i generate release i have error. when i switch off epgsql app start ok and i see all app (crypto, ssl, public_key are loaded), but if add epgsql again have error.

what am I doing wrong?

1 Answers1

1

I was struggling with the same problem myself. I found that even if I put epgsql dependency into the app file, but don't use any of its modules in the code then epgsql application isn't included into the release. It turned out this isn't a rebar's problem. Under the hood rebar uses reltool. This is reltool that actually generates the release and it seems to me that it uses some information from beam files and itself strips not used applications.

So to fix the problem I figured out two ways:

  • a. use any epgsql's module in the code, even pgsql:yyy() works :)
  • b. add {app, epgsql, [{incl_cond, include}]} into reltool.config.

In fact this is a general problem and isn't epgsql specific.

ten0s
  • 839
  • 8
  • 11