Fork me on GitHub
#boot
<
2017-03-09
>
chris-andrews03:03:38

^ nevermind, fixed on the newest WSL build

pesterhazy12:03:15

Is there a way to reuse a built-in task name in boot? For example if I want to make a task called repl in my build.boot.

pesterhazy12:03:15

I get

java.lang.IllegalStateException: repl already refers to: #'boot.task.built-in/repl in namespace: boot.user

pesterhazy12:03:54

(ns-unmap 'boot.user 'repl)
(require '[boot.task.built-in])

(deftask repl []
  (comp
   (with-pass-thru _
     (println "it works"))
   (boot.task.built-in/repl)))

pesterhazy12:03:54

the question came up because I'm thinking of suggesting a new built-in task boot run

pesterhazy12:03:32

you'd use it in either as boot run --function my.app/start-server or as boot run --eval "(+ 3 4)"

pesterhazy12:03:20

it's kind of like boot -e except that it can run as part of a pipeline

pesterhazy12:03:56

the reasoning is that most people end up implementing this as part of their build.boot, but then they need to learn about with-pass-thru

pesterhazy12:03:22

but one worry would be that lots of people already use run as a task name

pesterhazy12:03:48

so that adding that as a built-in would break things for them when upgrading to a new version

dominicm13:03:39

That would be handy actually

dominicm13:03:55

I didn't know about the ns-unmap trick either, I might use that.

dominicm13:03:07

Especially as cider is configured to run boot repl by default,

martinklepsch13:03:21

I think Alan and Micha were pretty eager to not have too generic task names so people could define their own run/build etc tasks. With a different name I think this might be a good addition

dominicm13:03:10

eval maybe? Except that shadows clojure.core

dominicm13:03:25

run aligns with leiningen, so I get that choice of name

mccraigmccraig14:03:48

i would like a boot task to do some sed like transforms on files in the fileset - does such a thing exist already ?

micha14:03:24

@mccraigmccraig we would like to add a --update option to the sift task for that

micha14:03:39

so you could modify files with it

micha14:03:50

since that is a pretty common type of task to make

mccraigmccraig14:03:01

so something like update {<str/replace-match> <str/replace-replacement>} for a line-by-line update ?

mccraigmccraig14:03:52

ah, i guess it would need a notion of which files to target too

mccraigmccraig14:03:00

so :update {regex [<str/replace-match> <str/replace-replacement>]}

pesterhazy14:03:55

I've pushed a PR with a new task to call arbitrary functions/code as mentioned above: https://github.com/boot-clj/boot/pull/597

pesterhazy14:03:47

The task name I came up with is call, which is less generic than run and less likely to be used in existing projects.

pesterhazy14:03:56

I also considered do and eval but both clash with clojure.core in potentially confusing ways

mccraigmccraig15:03:48

is an option with docstring like u update FMATCH=LMATCH:REPLACE #{[str str str]} "Runs str/replace on lines of files with paths which match FMATCH" the sort of addition to sift you were thinking of @micha ?

micha15:03:20

i wasn't thinking string replace, was thinking maybe some kind of transformer function or something?

mccraigmccraig15:03:02

oh, right, so not something that could be specified from the command-line ?

micha15:03:07

a lot of times you want to transform edn or json or things like that

micha15:03:34

we could include some built-in transformer functions, like string replace

micha15:03:21

yeah maybe this would be better as its own task, because then it could support positional parameters

micha15:03:57

boot ... [ rewrite --match '^.*/foo\.edn$' --transform string-replace FOO BAR ] ...

micha15:03:15

(boot ... (rewrite :match #"^.*/foo\.edn$" :transform string-replace "FOO" "BAR") ...)

mccraigmccraig15:03:17

ok, well i need something like that now - i'll have a go at it

kommen15:03:26

is there a way to kill/restart a pipeline from the boot repl which is started from the command line? i.e. if I have

(deftask dev []
  (comp
   (repl)
   (watch)
   (cljs)))
1. $ boot dev 2. connect to the repl and restart dev from the repl

micha15:03:04

not that i know of

micha15:03:09

normally you would do boot repl and then do boot.user=> (def p (future (boot (dev))))

micha15:03:37

then you can do boot.user=> (cancel-future p) or @p and press ctrl-c

micha15:03:03

you'd need to remove the repl task from the dev pipeline of course

micha15:03:07

in that scenario

kommen15:03:49

yeah, my scenario is that boot is started within a more complex setup within docker-compose, so it is running inside a docker container to work out of the box

micha15:03:10

why wouldn't that work with docker though?

micha15:03:35

you'd just have the docker thing get you to the clojure repl

micha15:03:40

and then take it from there

kommen15:03:36

right, but then everybody has to start the task. goal of the setup is that you just run the docker stuff and eveything is up and running. people not working on the clojure part shouldn’t have to worry about it

micha15:03:57

then the current thing would work, no?

micha15:03:03

since they won't be doing stuff in the repl anyway

micha15:03:28

if you're working on the clojure part you'd be restarting things in the repl

micha15:03:36

so you could use the second approach for them

kommen15:03:12

yeah, I’ll see if I can make that configureable somehow

mobileink16:03:57

hey folks, boot-http/serve seems to be disabling watch. this works:

(deftask monitor
  "watch etc."
  []
  (comp (build)
        (watch)
        (notify :audible true)
        (demos)))

mobileink20:03:02

watch as i try to use threads correctly. still having probs. also having probs with my checkouts not being reloaded.

pandeiro19:03:28

hey there, so i don't think it disables watch, but i have had issues with static resources that have changed not being 'seen' by the resource-serving handler

pandeiro19:03:01

there is a (sadly, >1 year old) issue for that particular bug: https://github.com/pandeiro/boot-http/issues/29

mobileink21:03:05

ok, thanks. i'll try to find some time to look into it. i'm also having ptoblems with boot-refresh, so i might as well look at everythin.

mobileink16:03:30

but if i insert (serve) just before (watch), then changes are no longer detected. what am I doing wrong?

mobileink20:03:33

anybody? on a related note, when i try to use https://github.com/samestep/boot-refresh

mobileink20:03:18

it complains about aliases already defined in build.boot.

chancerussell17:03:07

I’m wondering what level of abstraction to use for builds that involve multiple separate modules

chancerussell17:03:25

Say I have a project that is going to be build into a macos .app bundle

chancerussell17:03:53

And I need to generate a JAR with some jvm code, but also a directory of compiled clojurescript files

chancerussell17:03:40

If I want to point the cljs compiler to one directory, run it, then point the jar task to a different set of source/resource dirs and run that

chancerussell17:03:13

Then take all this output and bundle it together

chancerussell17:03:48

Am I stuck pulling stuff in and out of the environment with set-env!?

chancerussell17:03:08

I’m not sure if this is the problem pods are meant to solve

micha17:03:04

pods solve the problem of how to manage components that need conflicting versions of the same dependencies

micha17:03:44

also they solve the problem of how to isolate the dependencies of independent components that are loaded into the same JVM

chancerussell17:03:37

That was the impression I got

hiredman18:03:37

someone helpfully pointed at https://github.com/boot-clj/boot/wiki/Configuring-Boot#configuring-stack-trace-display to me, to get boot stacktraces printing more in line with standard stacktraces, is there some way to disable aviso entirely?

alandipert18:03:26

@hiredman unfortunately no but agree it would be great to be able

alandipert18:03:24

was chatting with micha the other day, was probably a mistake to both bring it in and make it default

alandipert18:03:51

as a piece of UI it's subject to shed color churn

pesterhazy18:03:20

@hiredman @alandipert not a general solution but this pull request (https://github.com/boot-clj/boot/pull/582) will give you regular stack traces in a "bare repl":

boot repl -B
boot.user=> (require 'clojure.repl)
nil
boot.user=> (/ 1 0)
ArithmeticException Divide by zero  clojure.lang.Numbers.divide (Numbers.java:158)
boot.user=> (clojure.repl/pst)
ArithmeticException Divide by zero
	clojure.lang.Numbers.divide (Numbers.java:158)
	clojure.lang.Numbers.divide (Numbers.java:3808)
	boot.user/eval43 (boot.user5503644062414151444.clj:2)
	boot.user/eval43 (boot.user5503644062414151444.clj:2)
	clojure.lang.Compiler.eval (Compiler.java:6927)
	clojure.lang.Compiler.eval (Compiler.java:6890)
	clojure.core/eval (core.clj:3105)
	clojure.core/eval (core.clj:3101)
	clojure.main/repl/read-eval-print--7408/fn--7411 (main.clj:240)
	clojure.main/repl/read-eval-print--7408 (main.clj:240)
	clojure.main/repl/fn--7417 (main.clj:258)
	clojure.main/repl (main.clj:258)
nil

hiredman18:03:56

I ended up with

(alter-var-root
 #'boot.from.io.aviso.exception/write-exception
 (constantly
  (fn
    ([exception]
       (.printStackTrace exception *out*))
    ([writer exception]
       (.printStackTrace exception writer))
    ([writer exception options]
       (.printStackTrace exception writer)))))  
in my build.boot

alandipert19:03:43

ah yeah, i've put something like that in my profile.boot in the past also