Build better Erlang.

Ask A Question



Importing multi-app project

I have a project with multiple OTP apps in it. And I would like to import this project into another project via rebar dependency. And from the new project rebar3 could not see all subprojects defined in the first project. For example, `foo` is parent project and `bar` is trying to include `foo` into it. The app structure for foo looks like this. ``` root@900f642ef568:~/Developer/foo# rebar3 tree ===> Verifying dependencies... ├─ foo─0.1.0 (project app) ├─ foo_app1─0.1.0 (project app) ├─ foo_app2─0.1.0 (project app) └─ foo_app3─0.1.0 (project app) ``` And the directory structure looks like this: ``` root@900f642ef568:~/Developer/foo# tree -d . |-- apps | |-- foo_app1 | | `-- src | |-- foo_app2 | | `-- src | `-- foo_app3 | `-- src `-- src 8 directories ``` I am including this project into another project called bar and after doing `rebar3 get-deps` ``` root@900f642ef568:~/Developer/bar# tree -d . |-- _build | `-- default | `-- lib | `-- foo | |-- apps | | |-- foo_app1 | | | `-- src | | |-- foo_app2 | | | `-- src | | `-- foo_app3 | | `-- src | `-- src `-- src 13 directories ``` And my rebar tree looks like this: ``` root@900f642ef568:~/Developer/bar# rebar3 tree ===> Verifying dependencies... └─ bar─0.1.0 (project app) └─ foo─0.1.0 (git repo) ``` I would like to use `foo_app1` in this project bar (included this in ``). As you can see from the above `rebar3 tree` output, `foo_app1` is not listed as an app that is discovered. Because of which, when I try to launch `bar`, I get the error saying that ``` root@cello:~/Developer/bar# rebar3 shell ===> Verifying dependencies... ===> Compiling bar Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:0] [hipe] [kernel-poll:false] Eshell V9.2 (abort with ^G) 1> ===> The rebar3 shell is a development tool; to deploy applications in production, consider using releases ( ===> Failed to boot foo_app1 for reason {"no such file or directory", ""} 1> ``` Can someone please help me how to make rebar3 see the app `foo_app1`?

Posted by Vasu Dasari about a year ago


rebar3_erlydtl_plugin windows fails

After reviewing alot comments regarding usage of the rebar3_erlydtl_plugin, I am having trouble compiling the template files to the destination ebin directory. I added the DEBUG=1 setting to see the details of rebar3 build and additional tags to try to extract what erlydtl library is complaining about. Below is the setting in the local rebar.config file for subfolder that contains the "priv folder with the web content. {erlydtl_opts, [ {doc_root, "priv/templates"}, {out_dir, "ebin"}, {compiler_options, [report_errors, return, verbose, debug_info]}, {source_ext, ".dtl"}, {module_ext, "_view"}, {return, true}, {report, true} ]}. {plugins, [ {rebar3_erlydtl_plugin, ".*", {git, "", {branch, "master"}}} ]}. {provider_hooks, [ {pre, [{compile, {erlydtl, compile}}]} ]}. Below is the partial output of the rebar3 showing that it doesn't recognize the out_dir folder; however, the path is correct and I suspect that the symlinks may be the issue, since windows seem to behave as it should with them. ===> run_hooks("c:/SPRTVL/source/dashboard", pre_hooks, compile) -> no hooks defined ===> sh info: cwd: "c:/SPRTVL/source/dashboard" cmd: cmd /c mklink /j "c:\\SPRTVL\\source\\dashboard\\_build\\default\\lib\\web\\priv" "c:\\SPRTVL\\source\\dashboard\\apps\\web\\priv" ===> opts: [{use_stdout,false},return_on_error] ===> Port Cmd: cmd /q /c cmd /c mklink /j "c:\\SPRTVL\\source\\dashboard\\_build\\default\\lib\\web\\priv" "c:\\SPRTVL\\source\\dashboard\\apps\\web\\priv" Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof] ===> sh info: cwd: "c:/SPRTVL/source/dashboard" cmd: cmd /c mklink /j "c:\\SPRTVL\\source\\dashboard\\_build\\default\\lib\\web\\include" "c:\\SPRTVL\\source\\dashboard\\apps\\web\\include" ===> opts: [{use_stdout,false},return_on_error] ===> Port Cmd: cmd /q /c cmd /c mklink /j "c:\\SPRTVL\\source\\dashboard\\_build\\default\\lib\\web\\include" "c:\\SPRTVL\\source\\dashboard\\apps\\web\\include" Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof] ===> sh info: cwd: "c:/SPRTVL/source/dashboard" cmd: cmd /c mklink /j "c:\\SPRTVL\\source\\dashboard\\_build\\default\\lib\\web\\src" "c:\\SPRTVL\\source\\dashboard\\apps\\web\\src" ===> opts: [{use_stdout,false},return_on_error] ===> Port Cmd: cmd /q /c cmd /c mklink /j "c:\\SPRTVL\\source\\dashboard\\_build\\default\\lib\\web\\src" "c:\\SPRTVL\\source\\dashboard\\apps\\web\\src" Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof] ===> Compiling web ===> Running erlydtl... ===> Compiling "c:/SPRTVL/source/dashboard/apps/web/priv/templates/tl.dtl" -> "c:/SPRTVL/source/dashboard/_build/default/lib/web/ebin/tl_view.beam" with options: [{compiler_options,[report_errors,return,verbose,debug_info]}, {custom_tags_dir,"c:/SPRTVL/source/dashboard/apps/web"}, {doc_root,"c:/SPRTVL/source/dashboard/apps/web/priv/templates"}, {out_dir,"ebin"}, {compiler_options,[report_errors,return,verbose,debug_info]}, {out_dir,"c:/SPRTVL/source/dashboard/_build/default/lib/web/ebin"}, {source_ext,".dtl"}, {module_ext,"_view"}, {return,true}, {report,true}] c:/SPRTVL/source/dashboard/apps/web/priv/templates/tl.dtl: Failed to write file: no such file or directory ===> Compiling apps/web/priv/templates/tl.dtl failed c:/SPRTVL/source/dashboard/apps/web/priv/templates/tl.dtl:none: Failed to write file: no such file or directory ===> Compilation failed: {error, [["c:/SPRTVL/source/dashboard/apps/web/priv/templates/tl.dtl:none: Failed to write file: no such file or directory\n"]], []}

Posted by Jeff Starnes about a year ago


Compilation fails because lager isn't compiled first (even though it is the first dep listed in rebar.config)

I'm sure people asked this question gazillion times already, but I couldn't find a better answer to fix below problem than first run `make compile` which fails (see below), then manually cd into `_build/default/lib/lager` and run `make all` and then go back to ../../../.. and rerun `make compile` I would greatly appreciate your feedback. My understanding is rebar3 is designed to compile dependencies in the order they are listed, but it doesn't work this way for me: >cat rebar.config {erl_opts, [debug_info, {parse_transform, lager_transform}]}. {deps, [ %% lager isn't available out of the box with embedded version of Erlang I'm using {lager, ".*", {git, "", {branch, "master"}}}, ... rest of hello_app deps ]}. {cover_enabled, true}. {relx, [{release, {hello_app, "1.0"}, [lager, other apps..., hello_app ]}, . . . >make prod-release rebar3 release ===> Verifying dependencies... ===> Fetching lager ({git,"", {ref,"c3970a99131c7c73de7eba3c2a569806fe47e40a"}}) ===> Fetching hello_app ({git,... ===> Fetching goldrush ({pkg,<<"goldrush">>,<<"0.1.9">>}) ===> Downloaded package, caching at /root/.cache/rebar3/hex/default/packages/goldrush-0.1.9.tar ===> Compiling hello_app <=== WHY NOT lager first? ===> Compiling _build/default/lib/hello_app/src/gen_hello.erl failed _build/default/lib/hello_app/src/gen_hello.erl:none: undefined parse transform 'lager_transform' make: *** [Makefile:38: release] Error 1

Posted by Irina Guberman about a year ago


Relups with Rebar3

I am trying to get a super basic minimal hot code loading example running. How is the overall process supposed to work? I have tried this example as well, but got errors: I make my first version, compile, create the release and run it. So far everything works fine. Now how do I make another version of my application to use in a new release version? I add another release to the rebar.config like this: {release, { testserver_rel, "0.2.0" }, [{testserver_app, "0.2.0"}, sasl ]}, I upgrade my .app file to "0.2.0", I create an appup file, I compile and release and get: ===> Failed to solve release: Unable to solve constraints, the following solutions were attempted Unable to satisfy goal constraint (testserver_app = 0.2.0), sasl due to constraint on sasl -> (testserver_app = 0.2.0) If I remove the "0.2.0" part from the rebar.config, it works, but the release uses application "0.1.0" and not "0.2.0". If on the other hand I create a completely separate folder for the release with a new rebar.config and everything (for example I download the two branches from the above example into two separate folders, I can create both releases and they run, but when I use ./rebar3 relup I get: ===> could not find app testserver {0,1,0} I am probably doing something very simple wrong, but I can't find any documentation on how to do it properly. How can I keep two versions of an application in my folders? I just want to make 2 releases with different versions of the same application and then create a relup to switch between them. I got a bunch of other error messages while trying to fix this. I would be very grateful for any help! Thanks!

Posted by LP about a year ago