I am a newbie of erlang/cowboy, using rebar3 now, as 99's cowboy is using its own erlang.mk system, how can I use rebar3 to build a cowboy release? Thank you in advance.
Use the new command to create your project.
$ rebar3 new app yourapp
Then in your project path find rebar.config file and add cowboy as dependencie under the deps key:
{deps,
[{cowboy, {git, "git://github.com/ninenines/cowboy.git", {tag, "1.0.1"}}}]}.
Then using compile command rebar3 fetch defined dependencies and compile them as well as your application.
rebar3 compile
At the end for making a release you first need to create your release structure and then making a release with following commands.
$ rebar3 new release yourrel
$ rebar3 release
Note that basic usage example of Rebar3 is about cowboy in details.
Related
I have been trying to generate a rebar3 application, however I have encountered a problem, I have generated new app using rebar3, and when I try to compile it I get error as such:
> ===> Verifying dependencies...
> ===> Uncaught error in rebar_core.
The same error is given when I try to use rebar3 shell. However I can use command rebar3 shell in every other directory including sub directories of the generated application.
rebar3 version returns:
rebar 3.14.0-rc1+build.4613.reffb58aa1f on Erlang/OTP 22 Erts 10.6
I ahve no idea what might cause the error and will be thankfull for any suggestions.
Try do rebar clean and remove _build folder in your application, then try run rebar compile
Couple of ideas.
Try setting DEBUG and run your rebar3 command, i.e. export DEBUG=1.
You are running a release candidate for a new rebar3 version, maybe try the latest 3.13.X version.
Erlang Version = Erlang/OTP 19
I have created a new erlang application using rebar3
Here are the steps:
rebar3 new app myapp
rebar3 compile
rebar3 new release myrel
cd myrel
rebar3 release
cd myrel/myapp/_build/default/rel/myapp/bin
./myapp start
I get the following error:
init terminating in do_boot (cannot expand $ERTS_LIB_DIR in bootfile)
Crash dump is being written to: erl_crash.dump...done
Can someone please check what I am missing here?
Thanks.
If you do something like rebar3 as prod tar you should get a .tar.gz file that can be expanded on the server, with bin/myapp used to start/stop/attach. If you do something like rebar3 release, it'll build into _build/, with the start/stop script being in _build/default/rel/myapp/bin/myapp. Why are you using rebar3 new release myrel?
I am new to rebar and try to create a demo app to understand the flow.
I have downloaded rebar & ran bootstrap.
I created a project according to this manual:
justenough-otp1
when I run the compile it compiles all the files and when it runs it.
when i try to generate the app it gives me the following error:
WARN: 'generate' command does not apply to directory /users/olive/poznov/Downloads/rebar-master/learn/apps
Command 'generate' not understood or not applicable
i tried to run
./rebar generate
from both the parent folder and apps folder (of course changing the path in the rebar.config file)
any ideas what might cause the problem?
The generate command is used to build a release. It is much more than a simple application: it contains the VM, your application and all the libraries and dependencies needed. So it needs some more information to be generated. You can look at Erlang rebar tutorial: generating releases and upgrades or LYSE release with reltool for more information (learning from the Eralang documentation is much more difficult)
Is it possible to use rebar to create a simple project module skeleton that is not based on an OTP application ? Overall I want to use that project structure to become a library for other rebar generated applications.
The structure should be as follows:
/myprojectlib
/src
/ebin
/deps
The idea is to use it on the deps section of a rebar.config file:
{ deps, [myprojectlib] }.
At the moment, because myprojectlib is not a rebar project (and an OTP app) the rebar compilation fails with the message that it cannot identify myprojectlib, even if it is in the /deps directory of the target folder. I checked further and it appears that the deps of the rebar.config file only accepts other rebar projects, hence my need to create a simple rebar project which is not an OTP application.
Erlang libraries are apps. They are however called library apps.
You can create a sample library app with rebar create-lib libid=myprojectlib.
My relx configuration
{release,{socket,"0.1.0"}}.
{extend_start_script,true}.
My .app file
{application,socket,
[{description,[]},
{vsn,"1"},
{registered,[]},
{applications,[kernel,stdlib,cowboy]},
{mod,{socket,[]}},
{env,[{http_port,8080}]},
{modules,[socket_app,socket_socket_handler,socket_sup]}]}.
After compiling the application using rebar I run relx from my terminal and the following is the output that I get
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/home/akshat/Desktop/socket/ebin
/home/akshat/Desktop/socket/deps
/usr/lib/erlang/lib
===> Missing beam file hipe <<"/usr/lib/erlang/lib/hipe-3.10.2/ebin/hipe.beam">>
===> Resolving available OTP Releases from directories:
/home/akshat/Desktop/socket/ebin
/home/akshat/Desktop/socket/deps
/usr/lib/erlang/lib
No releases have been specified in the system!
I don't understand this message from relx. Does it not create the release for me?
How do I install hipe?
Update
After doing a fresh install of erlang I no longer get hipe error message. But rebar still says no releases have been specified by the system.
I was having the exact same issue until I enter in the root directory of the rebar3 project, and run the rebar3 compile, rebar3 release commands. It worked perfect.
$ > ls
enter code here
chatx rebar3
$ > cd chatx/
$ > rebar3 compile
===> Verifying dependencies...
===> Compiling chatx
$ > rebar3 release
===> Verifying dependencies...
===> Compiling chatx
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/studio/erlang/chatx/_build/default/lib
/Users/studio/erlang/chatx/apps
/Users/studio/kerl/20.2/lib
===> Resolved chatx-0.1.0
===> Dev mode enabled, release will be symlinked
===> release successfully created!
Got this working. Re-installing erlang got rid of the first problem i.e the hipe error message. What relx meant by
No releases have been specified by the system
is that I had not specified an application to assemble for release. My understanding was that since I had only one application I would not need to specify it explicitly. So my relx.config file now looks like
{release,{socket,"0.1.0"},[socket]}.
{extend_start_script,true}.
This works and I now have a release in my _rel folder.