Error: file exists in multiple modules

I have module a which depends on module b, and module c so zig fetched both of them in module a , module b also depends on module c, and because of that I am getting the error: file exists in multiple modules.

Is there any solution available at the moment within current state of zig package manager?

This means you have multiple modules that are importing the same file. The solution should be to only import the file directly in one module, and in the second module, instead of importing the file, access it through the other module that is importing the file. So change this:

mod1: imports somefiile.zig
mod2: imports somefile.zig

to this:

mod1: imports somefile.zig
mod2: imports mod1 (accesses somefile.zig through mod1)

In the case that neither of these modules can access each other, then the solution is to create a new module that exposes that file, and now the other two modules can share this new module as a dependency.

newmod: imports somefile Zig
mod1: imports newmod (accesses somefile.zig through newmod)
mod2: imports newmod (accesses somefile.zig through newmod)

1 Like

Thanks @marler8997, I have implemented it in same manner, was wondering if there’s any elegant solution (that I’m not aware of) with zig package management as there’s lot of manual work.