Fork me on GitHub
#polylith
<
2022-05-19
>
Travis19:05:07

HI guys, I am coming back to using polylith after some time and trying to remember what I am missing that might be causing a dependency issue. I have a component with some extra deps in the test alias. When I start a repl in for the dev project/test in vscode that dependency is not being seen. I have added the component to the extra paths in the test profile in the root deps.edn file as well. What may I be missing ?

imre19:05:43

What do you mean by not being seen? You try to require one of its namespaces in the repl and it cannot be found?

seancorfield19:05:30

@U096GDTLL How exactly are you starting your REPL? Are you supplying both :dev:test aliases, or just :dev?

Travis19:05:23

Correct, repl cannot use the dep. I am using :dev:test

seancorfield19:05:54

@U096GDTLL I would verify that by starting a REPL outside VS Code, using the :dev:test alias combo, and making sure you can require/import those test-only dependencies.

seancorfield19:05:20

If that works, then I double-check exactly how VS Code is starting a REPL.

seancorfield19:05:05

(FWIW, I always start my REPL outside VS Code because it tends to run for days or weeks whereas I'm restarting VS Code a lot more often)

Travis19:05:23

Cool, I will give it a shot

Travis20:05:16

same result unfortunately

Travis20:05:38

clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"0.9.0"},cider/cider-nrepl {:mvn/version,"0.27.4"}}}' -M:dev:test -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"

tengstrand20:05:40

If you are using profiles, then you should also give +default (or the alias/profile you want to activate).

Travis20:05:25

i currently don't have any profiles yet

imre20:05:21

any chance you could share what your test alias looks like? (anonymized perhaps?)

Travis20:05:35

:test {:extra-paths ["components/the-component/test"
                               ]
                     :extra-deps {poly/the-component {:local/root "components/the-component"}}}
                               

Travis20:05:40

pretty much it

imre20:05:39

I think I see it

imre20:05:12

Does poly/the-component reference this dep you seem to be missing in its :test alias?

Travis20:05:38

yeah, that component has the dependency in its local deps.edn

Travis20:05:59

under the extra deps in test of course

imre20:05:25

you'll need to add that dependency of the-component as a test dep in the top deps.edn

imre20:05:04

you are referring to the-component there, but tools.deps will only pull in the-component's top-level (non-aliased) deps via such a reference

Travis20:05:22

ah, so i have to do it more at a global level

seancorfield20:05:32

I thought @U096GDTLL said this was already in "the test profile in the root deps.edn file" but re-reading it I think he just had the test path, not the extra dependency?

Travis20:05:58

i only defined the dependency in the components dep.edn

workspace/components/the-component/deps.edn

imre20:05:31

if you want to follow the poly convention, you'd do this in your top level deps.edn:

:dev {:extra-paths ["components/the-component/src"] ;; cursive workaround
       :extra-deps {poly/the-component {:local/root "components/the-component"}}}
:test {:extra-paths ["components/the-component/test"] ;; tools deps workaround
         :extra-deps {that-test-dependency-you-are-missing { ...coordinates...}}}

Travis20:05:26

gotcha, ok. that does work. Misconception on my part

seancorfield20:05:37

I suspect this would be less of a foot-gun if poly test constructed the dependencies for :dev:test the same way it does for projects? It reads all of the bricks' :test deps to build the classpath when running tests for projects I think? Or am I misremembering?

seancorfield20:05:07

Hmm, no, looking at our projects deps.edn files, we have deps in :test that are duplicated from bricks' deps.edn :test aliases it seems...

seancorfield20:05:13

(our setup is slightly complicated by the fact that we're in the process of migrating legacy stuff to Polylith, so our bricks are used by legacy subprojects for dev/test/build as well as from projects 😕 )

Travis20:05:29

easy to get lost in the deps stuff sometimes for me, lol

imre20:05:07

@U04V70XH6 I think you remember right. The difference is that you rarely if ever dev-repl into a project that is not the development project

Hukka05:05:19

Excellent timing!

imre05:05:21

Feedback is welcome 🙂

Hukka05:05:41

I suppose I have to write some tests now :thinking_face:

😄 1