I am following this blog: http://maplekeycompany.blogspot.se/2012/03/very-basic-cowboy-setup.html
In short, I am trying to compile an application with rebar just as the person in the blog. Everything goes smoothly until I want to run the command:
./rebar get-deps compile generate
This then give me the following errors and warnings,
> User@user-:~/simple_server/rebar$ ./rebar get-deps compile generate
> ==> rebar (get-deps)
> ==> rebar (compile) Compiled src/simple_server.erl Compiled src/simple_server_http.erl src/simple_server_http_static.erl:5:
> Warning: behaviour cowboy_http_handler undefined Compiled
> src/simple_server_http_static.erl
> src/simple_server_http_catchall.erl:2: Warning: behaviour
> cowboy_http_handler undefined Compiled
> src/simple_server_http_catchall.erl WARN: 'generate' command does not
> apply to directory /home/harri/simple_server/rebar Command 'generate'
> not understood or not applicable
I have found a similar post with the same error:
Command 'generate' not understood or not applicable
I think the problem is in the reltool.config but do not know how to proceed, I changed the path to the following: {lib_dirs, ["home/user/simple_server/rebar"]}
Is there a problem with the path? How can rebar get access to all the src files and also the necessary rebar file to compile and build the application?
You need to make sure your directory structure and its contents are arranged so that rebar knows how to build everything in your system and generate a release for it. Your directory structure should look like this:
The
rel
directory holds all the information needed to generate a release, and theapps
directory is where the applications that make up your project live. Application dependencies live in thedeps
directory. Each app such asmyapp
andanother_app
under theapps
directory can have their ownrebar.config
files. While two or more such applications are possible here, normally you'd have just one and all others would be dependencies.In the top-level
project
directory there's also arebar.config
file with contents that look like this:If necessary, you can use rebar to generate your apps from application skeletons:
If an application has dependencies, you'll have to add a
rebar.config
to its directory and declare each dependency there. For example, ifmyapp
depends on applicationfoo
version 1.2, createapps/myapp/rebar.config
with these contents:When you run
rebar get-deps
, rebar will populate the top-leveldeps
directory to hold all dependencies, creatingdeps
if necessary. The top-levelrebar.config
can also declare dependencies if necessary.You also need to generate a node, necessary for your releases:
You then need to modify the
reltool.config
file generated by the previous step. You need to changeto
and just after the line
{incl_cond, derived},
add{mod_cond, derived},
so that releases contain only the applications needed for correct execution.Next, wherever the atom
'project'
appears, you need to replace it with the applications under theapps
directory. For our example, we'd change this part:to this:
and change this part:
to this:
You might also need to add the line:
to exclude the
hipe
application since sometimes it causes errors during release generation or when trying to run the release. Try without it first, but add it if you see errors related tohipe
when generating a release, or if attempts to run the generated release result in this sort of error:you'll need to add it.
With all this in place you can now execute:
and you should be able to successfully generate the release. Note that running
rebar generate
at the top level rather than in therel
dir will result in a harmless warning like this, which you can ignore:Finally, you can run the release. Here's how to run it with an interactive console:
or you could run
./rel/project/bin/project start
to start it in the background. Run./rel/project/bin/project
with no arguments to see all available options.