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
reldirectory holds all the information needed to generate a release, and theappsdirectory is where the applications that make up your project live. Application dependencies live in thedepsdirectory. Each app such asmyappandanother_appunder theappsdirectory can have their ownrebar.configfiles. 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
projectdirectory there's also arebar.configfile 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.configto its directory and declare each dependency there. For example, ifmyappdepends on applicationfooversion 1.2, createapps/myapp/rebar.configwith these contents:When you run
rebar get-deps, rebar will populate the top-leveldepsdirectory to hold all dependencies, creatingdepsif necessary. The top-levelrebar.configcan also declare dependencies if necessary.You also need to generate a node, necessary for your releases:
You then need to modify the
reltool.configfile 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 theappsdirectory. 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
hipeapplication 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 tohipewhen 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 generateat the top level rather than in thereldir 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 startto start it in the background. Run./rel/project/bin/projectwith no arguments to see all available options.