polylith

https://polylith.gitbook.io/ and https://github.com/polyfy/polylith
seancorfield 2021-03-26T20:33:52.001200Z

Hi! Continuing a discussion here about Polylith that started in the #architecture channel…

seancorfield 2021-03-26T20:34:37.002100Z

I’ve just added :poly as an alias in my dot-clojure file (once I’ve pushed it to GH, it’ll be in the README as well for folks to see).

seancorfield 2021-03-26T20:35:44.003Z

The docs say you can run clj -M:poly info but that says:

The command can only be executed from the workspace root, or by also passing in :: or ws-dir:DIR.
I was sort of expecting help on “what to do next?” but it sounds like info is not for that?

seancorfield 2021-03-26T20:36:55.003700Z

Next I tried:

$ clojure -M:poly 
  Unknown command ''. Type 'poly help' for help.
So maybe for both of those situations, offer help instead of the error?

seancorfield 2021-03-26T20:39:41.006300Z

Help does indeed provide a good amount of information, but I want to confirm I have the right version: I added :poly as a :git/url with the latest SHA from master (and I saw it being git clone’d) but the help shows the last released version:

$ clojure -M:poly help
  Poly 0.1.0-alpha9 (2020-12-23) - <https://github.com/polyfy/polylith>
...
Is that just because the version/date string hasn’t been changed yet?

tengstrand 2021-03-26T20:40:31.006500Z

…let me check.

tengstrand 2021-03-26T20:41:52.007300Z

Yes, 0.1.0-alpha9 is the latest released version.

seancorfield 2021-03-26T20:42:08.007600Z

I created a new workspace per the install guide:

$ clojure -M:poly create w name:polyex top-ns:seancorfield.hello
It would be nice if it printed out a confirmation of what it did.

seancorfield 2021-03-26T20:43:14.009400Z

Right, but running :poly based on the latest SHA from master and being told it’s 0.1.0-alpha9 from December made me think it’s not running the latest version from GH — what am I missing?

tengstrand 2021-03-26T20:43:37.010200Z

We have went with the “Unix style”, that are quite silent when you create things (like a directory) and only print out things if something goes wrong or if you are expected to do something. We could be more clear about that in the documentation though.

seancorfield 2021-03-26T20:43:53.010500Z

Also, after cd polyex I tried to run this in the brand new workspace:

$ clojure -M:poly info
Error building classpath. Prefix sha not supported, use full sha for polyfy/polylith
😞

seancorfield 2021-03-26T20:44:50.011200Z

The generated deps.edn file has:

:sha       "INSERT_LATEST_SHA_HERE"
which causes that error.

tengstrand 2021-03-26T20:45:44.011900Z

Yes, the documentation says that you should update the string “INSERT_LATEST_SHA_HERE”…

seancorfield 2021-03-26T20:46:02.012200Z

I did that in my dot-clojure file.

tengstrand 2021-03-26T20:46:38.013300Z

In the ./deps.edn file at the root?

seancorfield 2021-03-26T20:46:53.013700Z

My ~/.clojure/deps.edn file.

seancorfield 2021-03-26T20:47:10.014100Z

As in what’s in https://github.com/seancorfield/dot-clojure 🙂

seancorfield 2021-03-26T20:47:31.014700Z

(I haven’t pushed the change that contains :poly yet because I wanted to kick the tires first)

seancorfield 2021-03-26T20:48:12.015600Z

I’m just saying that it’s a very poor experience to have added :poly as an alias to your user deps.edn file, generate a new workspace, and then have :poly stop working!

tengstrand 2021-03-26T20:50:00.016800Z

But the dot-clojure project’s deps.edn file is not a valid workspace file (it doesn’t have the :polylithkeyword) or does it?

seancorfield 2021-03-26T20:52:01.018500Z

Your installation instructions say to add :poly as an alias to “your deps.edn” — and since folks won’t yet have created a Polylith workspace, they’ll add it to the user deps.edn file which is where people expect to add tooling they want to use globally.

seancorfield 2021-03-26T20:52:27.019100Z

So that’s where I added it, and updated the :sha value, so I could run the tool to create a workspace.

seancorfield 2021-03-26T20:52:41.019500Z

(after struggling to find how to get the help displayed!)

seancorfield 2021-03-26T20:53:27.020500Z

Then I went into this brand new workspace that I had created with the (global) :poly alias and tried to run clojure -M:poly info — because, again, that’s what your installation instructions implied I would be able to do.

seancorfield 2021-03-26T20:54:06.021500Z

And it did not work because the generated project hides the global alias that users would have added above, to get the Polylith tool working in the first place.

seancorfield 2021-03-26T20:54:14.021800Z

So… moving on…

seancorfield 2021-03-26T20:54:47.023Z

I edited the project deps.edn file to comment out the local :poly alias so I could continue to use my global alias.

tengstrand 2021-03-26T20:54:49.023100Z

This is valid input. We should move the section “Use the Polylith Tool as a dependency” further down the documentation, when the workspace is actually created. Good feedback.

tengstrand 2021-03-26T20:55:00.023500Z

Are you using Mac?

seancorfield 2021-03-26T20:55:40.024800Z

Yes, but that’s not relevant. I don’t want to install the command-line tool when I can just use it as an alias from my user deps.edn file and have it available on all my machines.

tengstrand 2021-03-26T20:55:58.025200Z

Okay, I understand.

seancorfield 2021-03-26T20:56:23.026Z

Anyway, I then tried to run the poly info command again and…

$ clojure -M:poly info
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/change/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/command/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/common/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/creator/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/creator/resources is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/deps/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/file/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/git/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/help/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/lib/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/path-finder/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/shell/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/test-helper/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/text-table/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/test-runner/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/user-config/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/user-input/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/util/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/validator/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/version/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/workspace/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/workspace-clj/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/components/ws-explorer/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
WARNING: Specified path /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/bases/poly-cli/src is external to project /Users/sean/.gitlibs/libs/polylith/clj-poly/ec38a83db7597e6f6f33dfbc1e4da665807ab091/projects/poly
  stable since: 38686f2

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

  project      alias  source
  --------------------------
  development  dev     x--  

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

seancorfield 2021-03-26T20:56:52.026700Z

I know this is an issue you’re working on — but many other folks trying Polylith for the first time will not know that.

tengstrand 2021-03-26T20:58:12.027900Z

Yes, good point. You could try the issue-66branch that I’m working on. It’s not ready for production, but you should get rid of all these warnings at least.

seancorfield 2021-03-26T20:58:32.028200Z

Thanks, good to know. Will try that in a minute.

tengstrand 2021-03-26T20:59:07.029Z

2d89676724e98d4c1b858c28c452cf2a64fc1b1c

seancorfield 2021-03-26T20:59:26.029600Z

Here’s my next complaint(!)… So I fired up VS Code to edit this new project and .cpcache and .lsp folders appeared: common tooling folders like that should probably be in the default .gitignore file you generate.

seancorfield 2021-03-26T21:00:30.031Z

With that new SHA:

$ clojure -M:poly info
Checking out: <https://github.com/polyfy/polylith.git> at 2d89676724e98d4c1b858c28c452cf2a64fc1b1c
  stable since: 38686f2

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

  project      alias  source
  --------------------------
  development  dev     x--  

  interface  brick   dev
  ----------------   ---
Excellent!

tengstrand 2021-03-26T21:00:33.031100Z

But you will have to create the workspace again, because it will not have the :polylith keyword in ./deps.edn but instead store them in ./workspace.edn.

seancorfield 2021-03-26T21:00:49.031500Z

OK, good to know. On it…

seancorfield 2021-03-26T21:03:07.032900Z

Yup, that went more smoothly:

(! 1031)-&gt; clojure -M:poly create w name:polyex top-ns:seancorfield.hello

Fri Mar 26 14:01:15
(sean)-(jobs:0)-(~/clojure)
(! 1032)-&gt; cd polyex/

Fri Mar 26 14:01:22
(sean)-(jobs:0)-(~/clojure/polyex)
(! 1033)-&gt; clojure -M:poly info
Error building classpath. Prefix sha not supported, use full sha for polyfy/polylith

Fri Mar 26 14:01:29
(sean)-(jobs:0)-(~/clojure/polyex)
(! 1034)-&gt; clojure -M:poly info
  stable since: ff4060c

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

  project      alias  source
  --------------------------
  development  dev     x--  

  interface  brick   dev
  ----------------   ---
(I forgot to #_#_:poly in the generated deps.edn again but it ran once I did that)

seancorfield 2021-03-26T21:04:01.033900Z

Good to see the Polylith stuff removed from deps.edn. Alex has said tools should not add top-level keys there (but it would be OK to add it under an alias, since aliases could just be data).

seancorfield 2021-03-26T21:04:41.034400Z

(but poly would need to read the project basis to be able to lookup the alias value)

tengstrand 2021-03-26T21:05:27.035100Z

We decided to put all workspace configuration in workspace.edn at the root. Feels quite clean to me.

seancorfield 2021-03-26T21:06:23.036100Z

Yup, nice and clean. I would have complained about it being in deps.edn 🙂

tengstrand 2021-03-26T21:06:26.036300Z

The documentation is also updated in the issue-66 branch, so it should be useful.

tengstrand 2021-03-26T21:07:06.037100Z

Each component and base have their own deps.ednfile also and that worked out quite well also.

seancorfield 2021-03-26T21:07:22.037700Z

Yeah, each subproject in our monorepo has deps.edn.

seancorfield 2021-03-26T21:07:34.038100Z

Did you read my blog post about how we did that in the end?

tengstrand 2021-03-26T21:08:28.038900Z

Yes, I read your blog post. I’m not sure I remember all the detalils though!

tengstrand 2021-03-26T21:11:40.042100Z

The components and bases are defined as :local/root dependencies in each project’s deps.edn file. The exception is the root ./deps.edn file which uses :extra-paths (for the :dev and :test aliases). The reason is that we couldn’t use the :loca-root approach because the testdirectories didn’t work out in the IDE.

seancorfield 2021-03-26T21:12:11.042700Z

Would you like me to summarize all of this conversation in an email and send it to you, so that Slack’s 10,000 message limit doesn’t cause it to be lost?

seancorfield 2021-03-26T21:12:37.043300Z

(although it’ll all be in both the ClojureVerse log website and on Zulip chat as well via the logging bots)

tengstrand 2021-03-26T21:12:40.043400Z

Yes, that would be nice.

seancorfield 2021-03-26T21:13:03.043800Z

Cool. Do you want to DM me an email address to send it to?

tengstrand 2021-03-26T21:13:59.044100Z

Sure, you can use info[at]polyfy[dot]com.

1
seancorfield 2021-03-26T21:14:34.044800Z

I’ll continue to work through the docs to build my first poly app and add any feedback from that as well…

tengstrand 2021-03-26T21:14:44.045100Z

Sounds cool!

seancorfield 2021-03-26T21:15:06.045800Z

I don’t want to keep you up later — I appreciate you hanging around to discuss/help.

tengstrand 2021-03-26T21:15:26.046200Z

No problem, this is my hobby 😉

tengstrand 2021-03-26T21:16:07.046700Z

I will be awake for at least one more hour, so no problem.

🦉 1
tengstrand 2021-03-26T21:22:40.047700Z

And one more (maybe obvious) thing, use the documentation for issue-66 .

1