5

I want to use lager as my log utility and I have orgnazied my proj as below:

proj\
  |
  |--lager\
  |    |--src\
  |    |--ebin\
  |    |--...
  |     
  |--logserver\
  |    |--src\
  |    |--ebin\
  |    |--rebar.config
  |    |--...
  |
  |--rebar
  |

However, when I try to compile logserver, I always got the following error:

D:\proj\logserver>..\rebar compile

==> logserver (compile)
src/logserver_app.erl:none: error in parse transform 'lager_transform': {undef,
                                             [{lager_transform,
                                               parse_transform,
                                               [[{attribute,1,file,
                                                  {"src/logserver_app.erl",1}},  
                                                  ...

Can anyone know the reason? Thanks!

These is some additional information:

  • I am using Windows OS and using latest version of Erlang and rebar and lager.
  • lager itself has already been compiled. We can find the D:\proj\logserver>dir ..\lager\ebin\lager_transform.beam (This will succeed)
  • rebar's config file(D:\proj\logserver\rebar.config):

    ... {erl_opts, [{parse_transform, lager_transform}, debug_info,{d,'TEST'}, {i, "include"}, {src_dirs, ["src"]}]}.

    {lib_dirs, ["..\lager\ebin"]}. ...

user1040933
  • 277
  • 5
  • 14

2 Answers2

6

If you already have lager in your deps then make sure that you move lager dependency first in rebar.config so that way it will compile first. Like so:

{deps,[
  lager,
  ..
]}.
2240
  • 1,547
  • 2
  • 12
  • 30
Jack Daniel's
  • 2,583
  • 22
  • 28
4

Did you add lager as a dependency in your rebar.config? I guess lager is not in the path.

From the rebar wiki:

To use lager in your application, you need to define it as a rebar dep or have some other way of including it in erlang’s path. You can then add the following option to the erlang compiler flags:

{parse_transform, lager_transform}

You can add 'lager' as a dependency by editing your rebar.config:

%% == Dependencies ==

%% Where to put any downloaded dependencies. Default is "deps"
{deps_dir, "deps"}.

%% What dependencies we have, dependencies can be of 3 forms, an application
%% name as an atom, eg. mochiweb, a name and a version (from the .app file), or
%% an application name, a version and the SCM details on how to fetch it (SCM
%% type, location and revision). Rebar currently supports git, hg, bzr and svn.
{deps, [application_name,
        {application_name, "1.0.*"},
        {application_name, "1.0.*",
         {git, "git://github.com/basho/rebar.git", {branch, "master"}}}]}.

In your case, that should be something like:

{deps, [{lager, ".*", {git, "git://github.com/basho/lager.git", "HEAD"}}]}.

More info about the rebar dependency manager here:

https://github.com/basho/rebar/wiki/Dependency-management

Roberto Aloi
  • 30,570
  • 21
  • 75
  • 112
  • Thanks. But my lager is located in my local directory. So how can I add it as a dependency ? – user1040933 Sep 19 '12 at 06:05
  • Just added rebar configuration for lager. – Roberto Aloi Sep 19 '12 at 13:13
  • I have been having similar issues. I have tried above suggestions with no success. see this :http://stackoverflow.com/questions/20813513/configuring-lager-i-get-this-error-undefined-parse-transform-lager-transform – Charles Okwuagwu Dec 28 '13 at 11:26
  • I'm total dumb with rebar3, but the foggy part for me was to catch where the "erlang compiler flags" were located according to rebar3.Turned out I had to change a line in rebar.config from this`{erl_opts, [debug_info]}.` to this `{erl_opts, [debug_info, {parse_transform, lager_transform}]}.` – Riccardo Manfrin May 15 '19 at 11:43