I am building a server based on 'cowboy', using 'jiffy' for json processing. The problem I am running into is that after starting the shell by executing the binary generated by rebar3, only 'cowboy' is functioning as expected, but I have no access to mnesia, which is part of OTP. Also running rebar3 using the .config file produces this output:
>There are missing function calls in the release.
===> Make sure all applications needed at runtime are included in the release.
===> db_access:init_tables/0 calls undefined function **mnesia:create_table/2**
===> db_access:insert_apod_entries/1 calls undefined function **mnesia:transaction/1**
===> db_access:insert_apod_entries/1 calls undefined function **mnesia:write/1**
If I start Erlang by issuing the command 'erl' then mnesia is availabe. I've include the rebar.config I'm using. Any help with this issue would be greatly appreciated.
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et
%% escript_incl_extra is for internal rebar-private use only.
%% Do not use outside rebar. Config interface is not stable.
{require_erts_vsn, ".*"}.
{require_otp_vsn, ".*"}.
{require_min_otp_vsn, ".*"}.
{escript_incl_extra, [{"priv/templates/*", "."}]}.
{include_src, false}.
{deps, [
{jiffy, "1.1.1", "deps/"},
{cowlib,"2.11.0", "deps/"},
{cowboy, "2.9.0", "deps/"}
]}.
{erl_first_files, ["src/db_access.erl",
"src/tar_watch_handler.erl",
"star_watch_server_app.erl",
"star_watch_server_sup.erl"
]}.
% {artifacts, ["/home/oleg/Projects/erlang_practice/star_watch_server/deps/jiffy/priv/jiffy.so"]}.
{plugins, [
{ pc, {git, "git@github.com:blt/port_compiler.git", {branch, "master"}}}
]}.
{overrides,
[{override, jiffy, [
{plugins, [pc]},
{artifacts, ["priv/jiffy.so"]},
{provider_hooks, [
{post,
[
{compile, {pc, compile}},
{clean, {pc, clean}}
]
}]
}
]}
]}.
{base_dir, "_build"}.
%% directory in '<base_dir>/<profile>/' where deps go
{deps_dir, "lib"}.
%% where rebar3 operates from; defaults to the current working directory
{root_dir, "."}.
%% where checkout dependencies are to be located
{checkouts_dir, "_checkouts"}.
%% where, under <base_dir>/<profile> checkout dependencies are to be built
{checkouts_out_dir, "checkouts"}.
%% directory in '<base_dir>/<profile>/' where plugins go
{plugins_dir, "plugins"}.
%% directories where OTP applications for the project can be located
{project_app_dirs, ["apps/*", "lib/*", "."]}.
%% Directories where source files for an OTP application can be found
{src_dirs, ["src"]}.
%% Paths to miscellaneous Erlang files to compile for an app
%% without including them in its modules list
{extra_src_dirs, []}.
%% Types dict:dict() and digraph:digraph() have been introduced in Erlang 17.
%% At the same time, their counterparts dict() and digraph() are to be
%% deprecated in Erlang 18. namespaced_types option is used to select proper
%% type name depending on the OTP version used.
{erl_opts,
[
{platform_define, "(linux|solaris|freebsd|darwin)", 'HAVE_SENDFILE'},
{platform_define, "(linux|freebsd)", 'BACKLOG', 128},
{platform_define, "R13", 'old_inets'},
{src_dirs, ["src"]}
]}.
{minimum_otp_vsn, "25.0.4"}.
{application_resource_extensions, [
".app.src.script", ".app.src"
]}.
{cover_enabled, true}.
{validate_app_modules, true}.
{base_dir, "_build"}.
%% directory in '<base_dir>/<profile>/' where deps go
{deps_dir, "lib"}.
%% where rebar3 operates from; defaults to the current working directory
{root_dir, "."}.
%% where checkout dependencies are to be located
{checkouts_dir, "_checkouts"}.
%% where, under <base_dir>/<profile> checkout dependencies are to be built
{checkouts_out_dir, "checkouts"}.
{xref_checks, []}.
{xref_queries,
[{"(XC - UC) || (XU - X - B
- (\"escript\":\"foldl\"/\"3\")
- (\"eunit_test\":\"function_wrapper\"/\"2\")
- (\"eflame\":\"apply\"/\"5\")
- (\"abnfc\":\"file\"/\"2\")
- (\"erlydtl\":\"compile\"/\"3\")
- (\"lfe_comp\":\"file\"/\"2\")
- (\"neotoma\":\"file\"/\"2\")
- (\"protobuffs_compile\":\"scan_file\"/\"2\")
- (\"gpb_compile\":\"file\"/\"2\")
- (\"gpb_compile\":\"format_error\"/\"1\")
- (\"diameter_codegen\":\"from_dict\"/\"4\")
- (\"diameter_dict_util\":\"format_error\"/\"1\")
- (\"diameter_dict_util\":\"parse\"/\"2\")
- (\"erlang\":\"timestamp\"/\"0\")
- (\"rebar_rnd\":\"seed\"/\"1\")
- (\"rebar_rnd\":\"uniform\"/\"0\"))",
[]}]}.
{dialyzer,
[
{plt_extra_apps, [diameter]},
{warnings,
[
unmatched_returns,
error_handling,
race_conditions
]}
]}.
You will need to add mnesia to your app's app.src file.
From http://rebar3.org/docs/workflow/#setting-up-dependencies
If the dependency is needed at runtime by your application in order for it to work (e.g. you need a web server or call the library directly), add it to your application’s .app.src file under the {applications, [stdlib, kernel, ...]} tuple.
The tool that generates the release (relx) also uses the same definition to figure out which applications to include in the release.