简体   繁体   English

如何解决 erlang 钢筋的依赖性问题?

[英]How to resolve dependency issues with erlang rebar?

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...我正在尝试将 swagger 添加到现有的演示项目erlang_rest_api作为学习经验,但我似乎并没有走得太远......

I cloned the repos:我克隆了回购:

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

Then I added cowboy_swagger to rebar.config :然后我将 cowboy_swagger 添加到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 :所以我添加到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:然后我删除deps目录并再次构建:

...
==> 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. katana_test似乎是某种测试工具。 I tried adding that repos (inaka/katana-est) to rebar.config but it's not working, either.我尝试将该存储库(inaka/katana-est)添加到rebar.config ,但它也不起作用。

I also tried tagging cowboy as version "2.5.0" as listed in "undefined" earlier, but that made no difference.我还尝试将牛仔标记为前面“未定义”中列出的版本“2.5.0”,但这没有任何区别。

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?我是否缺少另一个依赖项?

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 .问题是由于cowboy_swagger是为与rebar3一起使用而构建的,并且它与旧钢筋不兼容,但 erlang_rest_api 使用的是旧钢筋,正如您在其Makefile中看到的那样。

The solution to your problem may be as simple as using rebar3 to build the project.您的问题的解决方案可能就像使用 rebar3 构建项目一样简单。 But careful if you do that since that would break make run and make run-local .但如果你这样做要小心,因为这会破坏make runmake run-local You'll have to figure out how to achieve the same results using releases.您必须弄清楚如何使用发布来获得相同的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM