Fork me on GitHub
#polylith
<
2023-02-22
>
timo12:02:32

I am trying out polylith architecture but getting Error 108 after adding my first two components. This is Error 108:

Error 108 - Components with an interface that is implemented by more than one
              component are not allowed for the development project.
    The solution is to remove the component from the development project
    and define the paths for each component in separate profiles
    (including test paths).
Can someone explain to me what the underlying problem is? I don't see a component's interface that is implemented by more than one component.

timo13:02:15

I assume it is because one component has a dependency on the other component. Is this not possible?

seancorfield17:02:18

@U4GEXTNGZ Perhaps you copied one component to another and didn't change the ns?

seancorfield17:02:14

The error refers to profiles and swappable component implementations. So you have two different folders under components that both have the same <top-level>.<name>.interface namespace.

tengstrand18:02:30

Could you please show the specific error message. It should be something like:

seancorfield18:02:03

Perhaps an old version of the poly tool that had different wording?

tengstrand20:02:07

If the interface is e.g. user then you can run this command to see which components that implement it: poly ws get:interfaces:user:implementing-components.

timo20:02:43

Thanks all, will come back to this tomorrow

timo11:02:58

mmh, I set up the whole directory from scratch and it's gone. must have been a typo or some error I made. now it's gone. Thanks again.

timo12:02:13

ah, now I've got it again

timo12:02:44

timo@Zokolette> poly info                                                    ~/projects/datahike-polyrepo
  stable since: 73da28b

  projects: 1   interfaces: 1
  bases:    0   components: 3

  project        alias  status   dev
  ----------------------------   ---
  development *  dev     s--     s--

  interface  brick               dev
  ----------------------------   ---
  -          datahike-lib *      s--
  -          datahike-server *   s--
  -          datalog-parser *    s--

  Error 106: More than one component that implements the  interface was found in the development project: datahike-lib, datahike-server, datalog-parser
  Error 108: Components with an interface that is implemented by more than one component are not allowed for the development project. They should be added to development profiles instead: datahike-lib, datahike-server, datalog-parser
  Warning 205: Non top namespace datahike was found in datahike-lib.
  Warning 205: Non top namespace datahike-server was found in datahike-server.
  Warning 205: Non top namespace datahike-server.resources was found in datahike-server.
  Warning 205: Non top namespace datahike.backward-compatibility-test.src was found in datahike-lib.
  Warning 205: Non top namespace datahike.db was found in datahike-lib.
  Warning 205: Non top namespace datahike.experimental was found in datahike-lib.
  Warning 205: Non top namespace datahike.impl was found in datahike-lib.
  Warning 205: Non top namespace datahike.index was found in datahike-lib.
  Warning 205: Non top namespace datahike.index.hitchhiker-tree was found in datahike-lib.
  Warning 205: Non top namespace datahike.integration-test was found in datahike-lib.
  Warning 205: Non top namespace datahike.middleware was found in datahike-lib.
  Warning 205: Non top namespace datahike.test was found in datahike-lib.
  Warning 205: Non top namespace datahike.test.attribute-refs was found in datahike-lib.
  Warning 205: Non top namespace datahike.test.middleware was found in datahike-lib.
  Warning 205: Non top namespace datalog was found in datalog-parser.
  Warning 205: Non top namespace datalog.parser was found in datalog-parser.
  Warning 205: Non top namespace datalog.parser.impl was found in datalog-parser.
  Warning 205: Non top namespace datalog.parser.test was found in datalog-parser.
  Warning 205: Non top namespace deps.cljs was found in datahike-lib.
  Warning 205: Non top namespace js was found in datahike-lib.

timo12:02:06

Thing is... I did not even specify an interface anywhere.

tengstrand13:02:08

The top namespace is set to io.replikativ (the key :top-namespace in workspace.edn). If you look in e.g. components/datahike-lib/src the poly tool is therefore expecting a top namespace/directory io and a replikativ directory inside it. Now the top namespace is datahike and that's the reason the tool complains. You need either change the top namespace to "datahike" in workspace.edn or make sure all components use the top namespace io.replikativ.

tengstrand13:02:26

A component should follow this namespace convention: top-ns.interface-name. So if you have a component datahike-lib and you want it to implement an interface with the name datahike-lib then then a namespace x in that component should live in the namespace io.replikativ.datahike-lib.x and the directory structure under components/datahike-lib/srcand components/datahike-lib/test should therefore be io/replikativ/datahike_lib/x for the x namespace.

timo13:02:12

Alright, I knew that. The Warning 205 is explained pretty straightforward in commands.md. The Errors were throwing me off, they are just not clear to me. But you're saying they are disappearing once I rename my namespaces?

tengstrand14:02:54

Yes, every component has to live in the top namespace.

furkan3ayraktar16:02:33

@U1G0HH87L If the error is component does not have the correct top-namespace, the tool should not throw Error 106 and 108. It should only throw the Error 205. Also, in the output shared above, the poly tool states that there are components without an interface (indicated by a dash under the interface column). Since components can’t exists without an interface, instead of giving a wrong information, the tool should understand there is something wrong (in this case the top-namespace is not used properly) and report that instead. In the scenario above, a more meaningful error and output would be:

stable since: 73da28b

  projects: 1   interfaces: 0
  bases:    0   components: 0

  project        alias  status   dev
  ----------------------------   ---
  development *  dev     s--     s--

  interface  brick               dev
  ----------------------------   ---


Error XXX: Invalid component. Top namespace is not used in component datahike-lib
Error XXX: Invalid component. Top namespace is not used in component datahike-server
Error XXX: Invalid component. Top namespace is not used in component datalog-parser

tengstrand19:02:00

Yes, that makes sense. I added a comment to https://github.com/polyfy/polylith/issues/277.

🚀 4
tengstrand03:02:40

I have fixed the https://github.com/polyfy/polylith/issues/277 and merged it to master. It seems to work for your datahike-polyrepo repository, but you can have a look also @U4GEXTNGZ.

❤️ 6