Fork me on GitHub
#boot
<
2017-03-22
>
thheller11:03:42

hello! can someone point me to a quick example of how to execute clojure code via boot (in the context of the project, ie with its dependencies)?

thheller11:03:46

similar to lein run -m my.ns/fn with some args and from within a boot task if possible

thheller11:03:56

don't know where to look

thheller11:03:53

(require 'my.namespace)
(deftask run []
  (with-pass-thru _
    (my.namespace/-main)))

thheller11:03:28

is all I found, don't understand why the require is in the boot file though?

thheller11:03:45

how would I pass the CLI args to -main? boot seems to want me to specify them for the task

martinklepsch11:03:51

@thheller would you pass CLI args as a single string?

martinklepsch11:03:33

the issue here is probably that the boot invocation syntax is boot task1 —option value task2, i.e. if a “word” of the arg-string isn’t following an option it’s interpreted as a task

thheller11:03:49

at the moment its just one string yes, not too sure about CLI opts yet

thheller11:03:58

so there is no direct equivalent to lein run? I have to deftask it?

martinklepsch11:03:59

(deftask run 
  [o opts OPTIONS str “Your options]
  (with-pass-thru _
    (my.namespace/-main opts)))
boot run -o “--option value” 

thheller14:03:07

@martinklepsch it'll do, not really using boot ... just comparing to lein and checking that things are possible in boot as well without too much work

martinklepsch14:03:17

@thheller cool, looking forward to see what you’re cooking up 🙂 feel free to ping me here if you have any questions

twashing18:03:42

How do we know what the boot scopes are? So I can have [spyscope “0.1.5” :scope “dev”]?

twashing18:03:01

And how do I know that there’s a dev (or any other) scope?

micha18:03:04

@twashing that's a general Maven concept, not specific to boot

micha18:03:40

however, most of it isn't relevant to boot

micha18:03:09

everyone uses maven repositories to distribute artifacts now, even if you don't use maven the build tool

micha18:03:29

but maven repos were originally created to work with maven the build tool

twashing18:03:29

I just want to include spyscope for development, but not production.

micha18:03:40

that's not what scopes are for

twashing18:03:41

Right. That makes sense.

micha18:03:58

so what you'd do is just conditionally include them in your dependencies

micha18:03:07

since you're programming in clojure in your build.boot

micha18:03:10

you can do anything

micha18:03:15

here is a sample, one sec

twashing18:03:11

@micha Whoa! Sweet :)

twashing18:03:21

I see where you’re going with this. Thanks!

micha18:03:28

barp $ is my shell prompt

twashing18:03:47

I thought it was an arp command that shifted $1 of every transaction to …

twashing18:03:55

Meh. Bad joke. Never mind :)

ag20:03:12

has anyone seen this? for whatever reason adzerk/boot-cljs throwing exception java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Symbol. I can’t figure out what change that causing this

micha20:03:41

are you doing (defn [x] ... somewhere?

micha20:03:02

definitely seems like a macro issue anyway

richiardiandrea20:03:01

agree, vector and symbols, been there many times 😄

ag20:03:41

oh, right… it does look like that thing, let me see who’s that sucker intelligent person who broke it

mobileink20:03:36

boot-cljs is throwing this? not your source?

mobileink20:03:13

check your .cljs.edn files for a sym where you should have a vector?

juhoteperi20:03:35

@ag Does the exception have any file/line info and stacktrace?

richiardiandrea20:03:03

@ag environ.boot/eval2342/fn/environ-middleware/environ-handler/fn boot.clj: 39

richiardiandrea20:03:26

It is suspicious

juhoteperi20:03:08

that's probably just because of task middleware stack

richiardiandrea20:03:26

But might be totally off actually

juhoteperi20:03:45

@ag What value does your .cljs.edn have for :require property?

micha21:03:52

ah yeah i bet it's like :require [[foo.bar :as bar]] maybe

ag21:03:42

oh, ok… i found the issue… someone trying to add migrations with flyway, changed resources path

ag21:03:41

prob. boot needs better error message when can’t find .edn file

juhoteperi21:03:53

Hmm, boot-cljs should work fine without cljs.edn file

juhoteperi21:03:02

Shouldn't at least cause this problem

ag21:03:51

yah. for whatever reason things broke when :resource-paths #{”resources/public”} changed to #{”resources”}

ag21:03:57

¯\(ツ)

mobileink21:03:55

for posterity and those of us committed to making all possible mistakes, can you tell us exactly what caused the problem? the masses yearn.

mobileink21:03:40

i would not expect a mere change in paths to produce that error.

mobileink21:03:38

we can put it on the wiki under troubleshooting.

austin.chamberlin22:03:31

q for the room: I've just implemented my first boot task, which examines my source files and does some special checks on the data within, and i want this task to either 'pass' and or 'fail' much like running a unit test suite. At the moment it just prints out pass/fail, but can you recommend a way to make it truly 'fail' and abort the rest of the pipeline?

micha22:03:51

you can always throw an exception

micha22:03:06

that will terminate the pipeline unless some other task upstream catches it

micha22:03:28

the watch task, for example, will catch exceptions

micha22:03:35

and print the stack etc

austin.chamberlin22:03:53

yea, i can work w/ that, though i'm still wondering if there's a more canonical way to fail a task

micha22:03:19

exceptions are a good way to do nonlocal return

micha22:03:33

like to abort something with prejudice

micha22:03:46

imho 🙂

micha22:03:15

most of the built in tasks have assertions in them

austin.chamberlin22:03:15

okay cool, well thanks for yho