简体   繁体   English

如何混合管理包的相互依赖性?

[英]How to manage package interdependencies in mix?

I've got a couple useful libraries I've build for elixir. 我已经为Elixir建立了几个有用的库。 I've put them both up on hex. 我把它们都用十六进制表示。 I already use library A in library B, and I've just incorporated library B as a dependency for library A. Now of course library A won't build. 我已经在库B中使用库A,并且我刚刚将库B合并为库A的依赖项。现在当然不会构建库A。

Error while loading project :a at /Users/me/fun/a/deps/ar ** (Mix) Trying to load ArgumentParser.Mixfile from "/Users/me/fun/a/deps/a/mix.exs" but another project with the same name was already defined at "/Users/jistone/fun/a/mix.exs" 加载项目时出错:/ Users / me / fun / a / deps / ar **(混合)尝试从“ /Users/me/fun/a/deps/a/mix.exs”加载ArgumentParser.Mixfile已经在“ /Users/jistone/fun/a/mix.exs”中定义了另一个具有相同名称的项目

Here is what I have tried so far: 到目前为止,这是我尝试过的:

  • removing a from deps folder 除去a从DEPS夹
  • removing a from mix.lock 除去a从mix.lock
  • changing deps/b/mix.exs , adding a path: for the a deps entry to point to the project folder. 改变deps/b/mix.exs ,添加path:对于a DEPS条目指向的项目文件夹。
  • changing mix.exs for a and b to point at their respective project folders 更改mix.exs以使ab指向各自的项目文件夹

All fail with appropriate error messages. 全部失败,并显示相应的错误消息。

So question is: how to get mix to recognize a dependency is satisfied by the current project being built? 所以问题是:如何通过混合来识别当前正在构建的项目是否满足依赖关系?


edit: more details 编辑:更多详细信息

Package a is a library for parsing command line arguments. a是用于解析命令行参数的库。 Package b is a mix task for generating README.md files. 程序包b是用于生成README.md文件的混合任务。 In package b I used package a to parse the command line arguments for the mix task. 在程序包b我使用程序包a解析了mix任务的命令行参数。 Now I am trying to use the mix task to generate the README.md for package a , and I get the above failure. 现在,我尝试使用mix任务为程序包a生成README.md,但出现上述错误。

I can workaround by starting an iex session and loading the relevant beam files, but I'd like to get the mix task working if possible ... 我可以通过启动iex会话并加载相关的梁文件来解决,但我希望在可能的情况下使混合任务正常工作...

3 solutions I've found (none of them perfect) 我发现了3个解决方案(没有一个完美)

  • Building the readme docgen project as an escript and then removing it as a dependency. 将自述文件docgen项目构建为escript,然后将其删除为依赖项。

  • Changing the name of the project in the mix.exs file, generating the docs, then changing it back. 在mix.exs文件中更改项目名称,生成文档,然后将其更改回。

  • Loading all the beam files using the -pa arg in iex and running the code manually. 使用iex中的-pa arg加载所有梁文件并手动运行代码。

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

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