Fork me on GitHub
#boot
<
2018-10-05
>
borkdude08:10:53

@donaldball if you can’t do that, you might be better off using https://github.com/clojure/tools.cli directly

martinklepsch09:10:51

@donaldball you could have the tasks read defaults from an atom + one task to write to that atom

Chris12:10:20

@seancorfield Thanks for your advice. It turned out to be that private repo authentication was added to tools.deps since boot-tools-deps was last updated. I've put together a PR here: https://github.com/seancorfield/boot-tools-deps/pull/23

zalky15:10:47

Hi all: just following up if anyone has any feedback about when it's safe to set the boot environment. Setting the boot env at task construction time is a pretty standard pattern:

(deftask task
  []
  (set-env! ...)
  (comp (task-1) (task-2) ...))
But what about setting inline during task execution time:
(deftask task
  []
  (comp (load-env :env env) (task-1) (task-2) ...))
I can't seem to get load-env task to work properly. Have you seen this pattern? Would you expect it to work?

alandipert16:10:24

@zalky can you share the load-env task?

zalky16:10:07

Yeah, thanks for the response! This is what I have right now, though I've tried variations on it:

(deftask load-env
  [e env ENV code "Environment map"]
  (with-pre-wrap fileset
    (->> env
         (apply concat)
         (apply set-env!))
    (commit! fileset)))

alandipert17:10:34

hm, that looks like it should work, but it does some unnecessary things

alandipert17:10:37

(require '[boot.core :as core])

(core/deftask load-env
  [e env ENV code "Environment map"]
  :pre [(map? env)]
  (core/with-pass-thru _
    (doseq [[k v] env]
      (core/set-env! k v))))

(core/deftask show-env-key
  [k key KEY kw "Environment key"]
  (core/with-pass-thru _
    (println (str "key = " (core/get-env key)))))

(core/deftask foo []
  (comp (load-env :env {:foo 123})
        (show-env-key :key :foo)
        (load-env :env {:bar 321})
        (show-env-key :key :bar)))

alandipert17:10:29

that seems to update the env at the right time so that subsequent task handlers see the updated env, if i understand your intent correctly

zalky13:10:20

@alandipert, thanks again for the response! I was able to try your suggestion out this morning but it produced the same result as the first versions of the task. Interestingly, the environment appears to change, but the change is not producing intended effect in the system. What I'm actually doing is adding some source directories as :resource-paths to the environment, and then installing my project as a jar to the local maven repo. However the source never shows up in the resulting jar. When I load the :resource-paths at task construction time, everything works as intended, so I'm pretty sure the rest of the pipeline is correct.

zalky13:10:55

Ah, I think I figured it out! So it was the environment map itself that was the problem. Instead of providing a fn to update :resource-paths, I was just passing in a value for :resource-paths. At execution time, this overwrote important changes that downstream tasks like pom had made at construction time.

zalky13:10:24

Hmm, I'm now thinking this pattern is problematic because there's no guarantees about how downstream tasks are using the environment. They may do important things at construction time based on a partially configured environment.

zalky19:10:51

After some more digging, I don't think it was the overwriting... I'm kind of stumped.

seancorfield16:10:27

Thanks @cbowdon -- 0.4.6 released to Clojars with that PR merged in!

😀 4
seancorfield18:10:50

Just FYI (mostly for @alandipert) this issue is happening more frequently now https://github.com/boot-clj/boot/issues/715 (specifically the dynapath syntax error) and it's making Boot virtually unusable for us now.

seancorfield18:10:49

It's happening on maybe three out of four runs of our test suite, as the pods are being initialized (so, asynchronously and early in the process as our Boot pipeline spins up).