1
votes

I'm trying to add swagger to an existing demo project erlang_rest_api as a learning experience, but I don't seem to be getting very far...

I cloned the repos:

git clone https://github.com/dronowar/erlang_rest_api

Then I added cowboy_swagger to rebar.config:

{cowboy_swagger, ".*", {git, "git://github.com/inaka/cowboy_swagger.git"}}

And when I build I get:

Dependency not available: jsx-2.9.0 (undefined)
Dependency not available: cowboy-2.5.0 (undefined)
Dependency not available: ranch-1.6.2 (undefined)
Dependency not available: trails-2.1.0 (undefined)

So I add to rebar.config:

{jsx, ".*", {git, "git://github.com/talentdeficit/jsx.git", {tag, "2.9.0"}}},
{ranch, ".*", {git, "git://github.com/ninenines/ranch.git", {tag, "1.6.2"}}},
{trails, ".*", {git, "git://github.com/inaka/cowboy-trails.git", {tag, "2.1.0"}}},

And then I delete the deps directory and build again:

...
==> poolboy (get-deps)
==> sync (get-deps)
==> katana_test (get-deps)
==> jsx (get-deps)
ERROR: Failed to load erlang_rest_api/deps/trails/rebar.config: {error,
                                                                                      {34,
                                                                                       file,
                                                                                       {error,
                                                                                        function_clause,
                                                                                        [{erl_eval,
                                                                                          '-inside-an-interpreted-fun-',
                                                                                          [katana_test],
                                                                                          []},
                                                                                         {erl_eval,
                                                                                          eval_fun,
                                                                                          6,
                                                                                          [{file,
                                                                                            "erl_eval.erl"},
                                                                                           {line,
                                                                                            829}]},
                                                                                         {erl_eval,
                                                                                          expr_list,
                                                                                          6,
                                                                                          [{file,
                                                                                            "erl_eval.erl"},
                                                                                           {line,
                                                                                            888}]},
                                                                                         {erl_eval,
                                                                                          expr,
                                                                                          5,
                                                                                          [{file,
                                                                                            "erl_eval.erl"},
                                                                                           {line,
                                                                                            240}]},
                                                                                         {erl_eval,
                                                                                          expr_list,
                                                                                          6,
                                                                                          [{file,
                                                                                            "erl_eval.erl"},
                                                                                           {line,
                                                                                            888}]},
                                                                                         {erl_eval,
                                                                                          expr,
                                                                                          5,
                                                                                          [{file,
                                                                                            "erl_eval.erl"},
                                                                                           {line,
                                                                                            240}]},
                                                                                         {erl_eval,
                                                                                          eval_lc1,
                                                                                          6,
                                                                                          [{file,
                                                                                            "erl_eval.erl"},
                                                                                           {line,
                                                                                            706}]},
                                                                                         {erl_eval,
                                                                                          eval_generate,
                                                                                          7,
                                                                                          [{file,
                                                                                            "erl_eval.erl"},
                                                                                           {line,
                                                                                            735}]}]}}}
make: *** [Makefile:7: deps] Error 1

katana_test seems to be some kind of testing tool. I tried adding that repos (inaka/katana-est) to rebar.config but it's not working, either.

I also tried tagging cowboy as version "2.5.0" as listed in "undefined" earlier, but that made no difference.

Do we really need to this specific, listing every dependent repository of every dependency?

I also tried using hex instead:

    {jsx, ".*"},
    {ranch, ".*"},
    {trails, ".*"},
    {cowboy_swagger, "2.1.0"}

but I still got:

Dependency not available: jsx-.* (undefined)
Dependency not available: trails-.* (undefined)
Dependency not available: cowboy_swagger-2.1.0 (undefined)
ERROR: compile failed while processing 

Am I missing another dependency?

1
Please, update in body of question link from [1]: https://github.com/donowar/erlang_rest_api to [1]: https://github.com/dronowar/erlang_rest_api. You skip r in donowar, correct is will be dronowarViacheslav

1 Answers

1
votes

The problem arises from the fact that cowboy_swagger is built to be used with rebar3 and it's not compatible with the old rebar, but erlang_rest_api is using the old rebar, as you can see in its Makefile.

The solution to your problem may be as simple as using rebar3 to build the project. But careful if you do that since that would break make run and make run-local. You'll have to figure out how to achieve the same results using releases.