Ask a Question

How to include a .hrl file from a dependency?

Hi! I'd like to do some `-spec`ing of my module, and many of my functions return instances of datatypes from one of my dependencies (in this case, a [record representing compiled statement](https://github.com/epgsql/epgsql/blob/master/include/epgsql.hrl) from [epgsql](https://github.com/epgsql/epgsql). They get fetched into `_build`, but I'm sure there's a more elegant way to have my modules compiled rather than something like `include("../../../_build/default/lib/<dependency>")` that I'm unaware of due to my lack of experience with this system and Erlang in general. Maybe you can shed some light on this? Thanks! Sending my best :D

Locally installed dependency

Two questions: 1. If I have a library and would like to have a tar ball created that would only contain it (app/{ebin,priv}) without generating a release, so that it can be included in ERL_LIBS path after compilation, copying, how do I do it? By default rebar3 always seems to want to build a release, with `_build` containing a ton of other files, which are not needed when working on a library application. 2. If I want to include a dependency in the project via {deps, [{some_lib, ...}]}, and that 'some_lib' is already installed in the ERL_LIBS path. Is there a way to make sure that rebar3 doesn't pull that dependency from external repository?

Erlang VM flags (rebar3 shell)

Hi, I know you can specify rebar3 --name <NODE> but is there a means by which to configure the other vm flags (http://erlang.org/doc/man/erl.html) For example (not saying I want the below config) erl +W w +K true -sname arnie -extra +bertie Is there a means by which to configure the above running rebar3 shell?

Rebar3 load/recompile modules

After downgrading from erlang/otp21 to erlang/otp20, rebar3 commands like new/clean/compile/shell/report etc do not produce the output as expected. Instead I get the following error: =ERROR REPORT==== 21-Aug-2018::15:04:59 === Loading of /usr/local/bin/rebar3/rebar/ebin/rebar3.beam failed: badfile escript: exception error: undefined function rebar3:main/1 in function escript:run/2 (escript.erl, line 759) in call from escript:start/1 (escript.erl, line 277) in call from init:start_em/1 in call from init:do_boot/3 =ERROR REPORT==== 21-Aug-2018::15:04:59 === beam/beam_load.c(1863): Error loading module rebar3: This BEAM file was compiled for a later version of the run-time system than 20. To fix this, please recompile this module with an 20 compiler. (Use of opcode 160; this emulator supports only up to 159.) I have uninstalled and reinstalled rebar3 and looked up on the web for solutions as well but to no avail. Any help on this would be appreciated.

How to include Observer in a release

How do I ensure my release (either production or otherwise) has the necessary dependencies such that it can run observer or a remote, connected node running observer can connect to it?

how to manage library depedencies in Rebar3

I have an application that uses Yaws in embedded mode. In my rebar.config file, I included: {deps, [{'yaws', { git, "https://github.com/klacke/yaws.git"}}]}. Rebar3 pulled in the Yaws code and placed it in _build/default/lib/yaws. In my own code, I need to reference records defined in yaws.hrl, which is now located in _build/default/lib/yaws/include. In old Rebar, I just set 'lib_dirs' to this directory. But 'lib_dirs' no longer exists in Rebar3. Rebar3 documentation says it's not usually needed. But when I do 'Rebar3 compile', compiler can't find the needed records. What's the correct way of setting this up? Also, do I need to have a '-include' statement in my own code pointing to the '.hrl' file I need? If yes, do I set the directory structure to reference the .hrl inside of _build?

Local dependencies (aka path or file)

I am working on a legacy project which I already have successfully from rebar to rebar3. The next task is to extract a library which can be used by other tools not yet written. Also I am not yet allowed to put anything into separate SCM. Is there a way to reference the extracted library as a dependency via a local relative or absolute path?

Setting code path when using Rebar3

Suppose I have the following scenario: 1) $ rebar3 new app myApp 2) then I edit my source code in the 'src' directory 3) $ rebar3 compile 4) Now I want to run my application in the erlang shell. Prior versions of rebar creates the 'ebin' directory along side the 'src' directory. To run my application in the erlang shell, I add a 'code:add_path' call in my '.erlang' file that includes the new ebin directory. With Rebar3, the 'ebin' directory is buried deep within the '_build' directory. What's the recommended way to add the code path? Is there anyway to get rebar3 to do it for me automatically?

Help with erlydtl plugin in a project with `release` template

Hi friends! Thanks so much for all the great work — rebar3 continues to be fabulous and make my Erlang development lovely :) My question regards use of the [rebar3_erlydtl_plugin](https://github.com/tsloughter/rebar3_erlydtl_plugin): first, in both the [Plugins page](http://www.rebar3.org/docs/using-available-plugins#erlydtl) and the [project README](https://github.com/tsloughter/rebar3_erlydtl_plugin/blob/master/README.md), I found the fetch syntax to not work unless I changed the URL from `git://github.com:tsloughter/rebar3_erlydtl_plugin.git` to `[email protected]:tsloughter/rebar3_erlydtl_plugin.git`: setting `DEBUG=1` showed me git was failing the fetch, which is curious because the `git://` format works in `deps`. After I got it running however, `rebar3 erlydtl compile` fails when I run it from the top level of the releases template, which is to say, my project is split into `apps/otp_app1, apps/otp_app2, ...`. Digging into the source with `DEBUG` set, I find the issue is [here](https://github.com/tsloughter/rebar3_erlydtl_plugin/blob/master/src/rebar3_erlydtl_plugin.erl#L126), where the plugin [expects to be called from an OTP app](https://github.com/rebar/rebar3/blob/master/src/rebar_app_discover.erl#L131-L136) but, from the `release` template, can't delve into the appropriate subdirectories. I'm happy to submit a pull request for whatever is the best desired functionality for a case like this, but don't want to write something with design implications ("how does a plugin negotiate being run in the app template vs. release template") without asking the pros first, especially since I might be missing something basic in my config/invocation somewhere. Thanks!

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, "https://github.com/erlang-lager/lager", {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,"https://github.com/erlang-lager/lager", {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