Fork me on GitHub
#polylith
<
2022-01-14
>
Hukka06:01:47

Just starting to really use polylith after following it for acouple of years. Is there a way to create a workspace in an existing repo that only does the bare minimum without touching the gitignores? It managed to bork it and add a ton of cruft, even from things it's trying to ignore (for example it removed .lsp and added .lsp/sqlite*.db to gitignore, causing .lsp/.cache/sqlite.db to be added into the commit)

Hukka06:01:43

For now I think I'll just copy that workspace.edn, expunge the whole commit poly added automatically, and add the config manually back

Hukka07:01:53

Well, that didn't work so well:

$ poly info
#error {
 :cause class clojure.lang.PersistentVector cannot be cast to class clojure.lang.IPersistentMap (clojure.lang.PersistentVector and clojure.lang.IPersistentMap are in unnamed module of loader 'app')
 :via
 [{:type java.lang.ClassCastException
   :message class clojure.lang.PersistentVector cannot be cast to class clojure.lang.IPersistentMap (clojure.lang.PersistentVector and clojure.lang.IPersistentMap are in unnamed module of loader 'app')
   :at [clojure.core$ex_info invokeStatic core.clj 4771]}]
 :trace
 [[clojure.core$ex_info invokeStatic core.clj 4771]
  [polylith.clj.core.workspace_clj.config$dev_config_from_disk invokeStatic config.clj 9]
  [polylith.clj.core.workspace_clj.core$toolsdeps_ws_from_disk invokeStatic core.clj 60]
  [polylith.clj.core.workspace_clj.core$workspace_from_disk invokeStatic core.clj 126]
  [polylith.clj.core.workspace_clj.interface$workspace_from_disk invokeStatic interface.clj 4]
  [polylith.clj.core.command.core$read_workspace invokeStatic core.clj 52]
  [polylith.clj.core.command.core$workspace_reader_fn$fn__23531 invoke core.clj 59]
  [polylith.clj.core.command.core$execute invokeStatic core.clj 66]
  [polylith.clj.core.command.interface$execute_command invokeStatic interface.clj 4]
  [polylith.clj.core.poly_cli.core$_main invokeStatic core.clj 31]
  [polylith.clj.core.poly_cli.core$_main doInvoke core.clj 7]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [polylith.clj.core.poly_cli.core main nil -1]]}

Hukka07:01:23

I guess I'll try creating a brand new repo and see what actually is added

Hukka07:01:46

Ok, I had a missing deps.edn

👍 1
tengstrand07:01:13

There is an https://github.com/polyfy/polylith/issues/160 about this problem and I will probably start working on that and other things in the weekend.

Hukka09:01:44

Heh, good to know

ericdallo12:01:19

Note that .lsp/sqlite*db is outdated gitignore config, the correct is .lsp/.cache

ericdallo12:01:39

also probably it should add to gitignore .clj-kondo/.cache as well

tengstrand17:01:25

Please test the https://github.com/polyfy/polylith/tree/issue-160 and see if it works as expected. Also have a look at my comment in https://github.com/polyfy/polylith/issues/160. I updated the`.gitignore` file according to @UKFSJSM38’s comments here, and it will only be created if not already exists. @U8ZQ1J1RR

💯 1
Hukka07:01:53

Well, that didn't work so well:

$ poly info
#error {
 :cause class clojure.lang.PersistentVector cannot be cast to class clojure.lang.IPersistentMap (clojure.lang.PersistentVector and clojure.lang.IPersistentMap are in unnamed module of loader 'app')
 :via
 [{:type java.lang.ClassCastException
   :message class clojure.lang.PersistentVector cannot be cast to class clojure.lang.IPersistentMap (clojure.lang.PersistentVector and clojure.lang.IPersistentMap are in unnamed module of loader 'app')
   :at [clojure.core$ex_info invokeStatic core.clj 4771]}]
 :trace
 [[clojure.core$ex_info invokeStatic core.clj 4771]
  [polylith.clj.core.workspace_clj.config$dev_config_from_disk invokeStatic config.clj 9]
  [polylith.clj.core.workspace_clj.core$toolsdeps_ws_from_disk invokeStatic core.clj 60]
  [polylith.clj.core.workspace_clj.core$workspace_from_disk invokeStatic core.clj 126]
  [polylith.clj.core.workspace_clj.interface$workspace_from_disk invokeStatic interface.clj 4]
  [polylith.clj.core.command.core$read_workspace invokeStatic core.clj 52]
  [polylith.clj.core.command.core$workspace_reader_fn$fn__23531 invoke core.clj 59]
  [polylith.clj.core.command.core$execute invokeStatic core.clj 66]
  [polylith.clj.core.command.interface$execute_command invokeStatic interface.clj 4]
  [polylith.clj.core.poly_cli.core$_main invokeStatic core.clj 31]
  [polylith.clj.core.poly_cli.core$_main doInvoke core.clj 7]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [polylith.clj.core.poly_cli.core main nil -1]]}

dangercoder10:01:40

Anyone else who think it would be a good idea to have an example on how to use polylith interfaces and swap implementations in the poly-guide? I had an “aha-moment” when I realised how it works and the polylith structure now makes sense.

👍 1
seancorfield16:01:22

The poly tool docs have a while section on this with two implementations of a user component, one local and one remote.

David Vujic10:01:31

Ah, I think I found it. The section about Profiles describe how to have two components with the same interface, but with different implementations. As I understand it, the same interface means different interface.clj files (one for each component), but with the same function signatures. https://polylith.gitbook.io/poly/workflow/profile

David Vujic10:01:18

from the FAQ: ” … If any of them don’t implement the full set, then the tool will complain when running the check, info or test command. …”

David Vujic10:01:03

This confused me a bit, but when continue reading, it makes total sense: “… The components live in two separate directories, under the components directory, and both use the se.example.user namespace but with different implementations in their core namespace: ...”

Hukka12:01:10

Is there a reason why the realworld example has library deps in the workspace deps.edn and then under the bricks' deps.edn too?

dangercoder12:01:00

the deps.edn in the root is for the development project

dangercoder12:01:10

so that you can work with a single repl in the whole polylith code base

Hukka12:01:32

Sure, but as its' pulling in the bases and components, it seems to work just fine when those then depend on the libraries

dangercoder12:01:25

ah, sorry - read your question a bit too fast. I understand what you mean now.

dangercoder12:01:41

is this a similar question? might be because of Cursive @U8ZQ1J1RR

Hukka12:01:05

Hm, well maybe. I also noticed in the guides that part about paths, but didn't see anything about the libraries. While that question does say "libs" I understood it didn't mean really external libs

furkan3ayraktar16:01:16

Exactly, the duplication is for it to work with Cursive. Otherwise, duplication is not needed.

👍 1
seancorfield16:01:48

If you don't use Cursive, you just put external libs in the brick deps file, not in the root.

seancorfield16:01:15

The only duplication we have is across projects (which includes dev in the workspace deps file) for things that might differ between projects, such as database drivers.

Hukka06:01:51

Would it be sensible to make a comment about that, in the deps.edn of the example, and mention it on https://polylith.gitbook.io/poly/workflow/libraries?

tengstrand13:01:47

We have this note in the Testing section.

tengstrand14:01:36

It may be a good idea to say a few words about this in the libs section too.

Hukka18:01:37

Yeah, I noticed this one even before, but thought that it really is specific to the syntax for the local files, not that you also would need to duplicate the libraries

tengstrand18:01:03

Seems like it needs to be clarified. Thanks for pointing out.