Fork me on GitHub
#boot
<
2016-08-07
>
flyboarder02:08:26

It was mentioned that an NPM task was required last week so I whipped one up: https://github.com/degree9/boot-npm

richiardiandrea02:08:53

@flyboarder: i saw a blog post that

richiardiandrea02:08:47

Was talking about the fact that you need to reset after a while, maybe this task can automate that?

flyboarder03:08:37

@richiardiandrea: for sure! It will take a bit of expanding on the options but it is possible. I’ll open an issue for reference.

fossifoo06:08:03

@martinklepsch: exactly. you want both tests and sources in your classpath because they need to be loaded, but you only want to instrument sources, not tests

fossifoo06:08:31

so if the user munges them together, that would be fine for the running of tests, but it would also print coverage of the test packages which is probably not wanted

fossifoo09:08:10

this is really over my head. it seems that when i "require" some namespace in "with-eval-in" or (.require pod ...) something different happens (things get put into the classpath?!?) than when i eval code that includes the require ("Could not locate ... on classpath.")

fossifoo09:08:41

man, always strict into the bowels of any library i touch

fossifoo09:08:37

(pod/with-eval-in @pod
          (boot.pod/add-classpath ~test-dir)
          (doseq [ns '~code-namespaces] (require ns))
          (require 'cloverage.coverage)
          (cloverage.coverage/-main [email protected]))
phew, this finally does the trick.

juhoteperi10:08:09

@fossifoo: Cloverage allows selecting namespaces to instrument and test with regexes

fossifoo10:08:57

you mean for the question of how to provide the test-namespaces to the plugin?

juhoteperi10:08:50

In general. I only read last few messages.

fossifoo10:08:33

yes, but afaics i still have to put those into the classpath of the pod

fossifoo10:08:51

scanning the dir for namespaces outside or inside cloverage/the pod doesn't make much difference imho

juhoteperi10:08:27

All the clojure files should already be inside classpath

fossifoo10:08:47

only if you put your "test" directory into the :source-paths

fossifoo10:08:16

and then the user has to provide a regexp for me instead of a dir

fossifoo10:08:12

i think like it is now it's a bit more effort on the task side, but i can simply pass in the test directory or default to "test"

juhoteperi10:08:14

Then your task won't work properly with other boot tasks, e.g. those which create new files in fileset

fossifoo10:08:24

hmmm. so you think i should pre-wrap and put "test" onto the source-paths? having the user do this seems cumbersome

juhoteperi10:08:14

Existing test tasks presume that tests are already on source-paths (and fileset) and use regex to select the test namespaces

fossifoo10:08:17

you are right that a task that creates new tests could be possible, even if i don't know of any

fossifoo10:08:32

from what i see all the existing tasks don't care about the difference and just run tests in all namespaces

juhoteperi10:08:48

Yeah boot-test defaults to that, though regex can be provided

fossifoo10:08:03

which is fine for the "test" part, but not for the instrumentation/reporting

juhoteperi10:08:05

#".*-test" regex would probably work quite well for default filter, that's what I use in boot-alt-test

fossifoo10:08:39

so "boot alt-test" only works if you have test in your source-paths?

fossifoo10:08:19

i agree that sticking to one way of handling things makes sense

juhoteperi10:08:00

Boot-test also only works if the tests are in source-paths

juhoteperi10:08:16

But some users modify source-paths using set-env before running tests

juhoteperi10:08:47

I have tests always on source-paths and presume that tasks can deal with that

fossifoo10:08:34

okay, then i'll rewrite the task to also do it that way, so it's consistent

lambder17:08:46

hello, can anyone please tell me how to configure build.boot so changes to backend are watched and system is auto reset? I work on https://github.com/juxt/edge it has clojurescript auto rebuild and reloaded but not backend when I connect via nrepl and do: (reset) then the backend reloaded as expected how can I have it automatically?

pesterhazy17:08:49

@lambder: you can make a custom boot task that executes reload

pesterhazy17:08:07

Imagine where speak or notify would go in the boot pipeline

lambder17:08:19

but i got an error

pesterhazy17:08:28

it needs to be in scope of watch

pesterhazy17:08:34

what's the error?

lambder17:08:19

one sec, trying to reproduce it

lambder17:08:00

I'm not sure what (watch) scope is

lambder17:08:04

the task is:

lambder17:08:05

(deftask dev-system "Develop the server backend. The system is automatically started in the dev profile." [] (require 'reloaded.repl) (let [go (resolve 'reloaded.repl/go) reset (resolve 'reloaded.repl/reset)] (try (require 'user) (go) (reset) ; <<<<<<<< JUST ADDED THIS (catch Exception e (boot.util/fail "Exception while starting the system\n") (boot.util/print-ex e)))) identity)

lambder17:08:23

now the error is:

lambder17:08:24

Exception while starting the system java.lang.IllegalStateException: Can't set!: ns from non-binding thread ... clojure.tools.namespace.repl/do-refresh repl.clj: 95 clojure.tools.namespace.repl/refresh repl.clj: 145 ... reloaded.repl/reset repl.clj: 53 ... boot.user/eval30066/fn/fn boot.user6240738269266896564.clj: 19 boot.user/eval30066/fn boot.user6240738269266896564.clj: 19 ... boot.user/eval30098/fn boot.user6240738269266896564.clj: 21 ... clojure.core/apply core.clj: 630 boot.core/construct-tasks core.clj: 911 ... clojure.core/apply core.clj: 630 boot.core/boot/fn core.clj: 949 clojure.core/binding-conveyor-fn/fn core.clj: 1916 ...

lambder17:08:52

the line : (reset) ; <<<<<<<< JUST ADDED THIS

lambder17:08:57

causes the error

pesterhazy17:08:50

one error is that your boot task should return a fn

pesterhazy17:08:29

example:

(deftask run-main
  []
  (with-pre-wrap fileset
    (require 'example.core)
    ((resolve 'excample.core/-main))
    fileset))

pesterhazy17:08:17

encapsulate your reloading logic in a single fn that you can resolve and run in this way, that should work

lambder17:08:43

it returns identity which is a function

lambder17:08:19

but i think is see the point

pesterhazy17:08:19

right, but you want to run the code at pipeline-time, not at setup-time, if that makes sense

lambder17:08:32

my reset is not called as part of the returned fun, right?

lambder17:08:12

I've defined task:

lambder17:08:13

(deftask reset-backend [] (with-pre-wrap fileset (let [reset (resolve 'reloaded.repl/reset)] (reset) fileset)))

lambder17:08:19

testing it now

pesterhazy17:08:28

I think it's safer to require the ns as well

lambder17:08:48

no errors but it is not resetting

lambder17:08:10

I did changes to some backend generated html

lambder17:08:21

reloadded browser but see no update

lambder17:08:43

on other hand when i do:

lambder17:08:54

in which i run (reset)

lambder17:08:56

all is good

lambder17:08:25

ah i think i know

lambder17:08:37

I think i misused the new task

pesterhazy17:08:21

add a println/log message so you see if it's being called 🙂

lambder17:08:28

I got the build.boot:

lambder17:08:29

(deftask reset-backend [] (with-pre-wrap fileset (let [reset (resolve 'reloaded.repl/reset)] (reset) fileset)))

lambder17:08:37

(deftask dev "This is the main development entry point." [] (set-env! :dependencies #(vec (concat % '[[reloaded.repl "0.2.1"]]))) (set-env! :source-paths #(conj % "dev")) ;; Needed by tools.namespace to know where the source files are (apply clojure.tools.namespace.repl/set-refresh-dirs (get-env :directories)) (comp (watch) (speak) (sass :output-style :expanded) (reload :on-jsload 'edge.main/init) (cljs-repl :nrepl-opts {:client false :port repl-port :init-ns 'user}) ; this is also the server repl! (cljs :ids #{"edge"} :optimizations :none) (dev-system) (reset-backend) (target)))

lambder17:08:47

when I run : boot dev

lambder17:08:56

i got java.lang.IllegalStateException: Can't set!: ns from non-binding thread

pesterhazy17:08:25

maybe something to do with your reset function?

lambder17:08:27

I believe boot tasks are defined ok

lambder17:08:34

it is the nature of reloaded.repl/reset

lambder17:08:50

so my question should be rephrased : how do I use reloaded.repl/reset from boot

pesterhazy17:08:45

don't know what the error message means sorry

juhoteperi17:08:14

reloaded.repl does some repl magic which doesn't always work

lambder17:08:20

do I need to port my components to system?

juhoteperi17:08:46

but that should give some idea how to use tools.namespace to reload everything

juhoteperi17:08:42

though it seems to call c.t.n. directly instead of through reloaded.repl

pesterhazy17:08:49

by the way, I prefer manually reloading namespaces from the editor

juhoteperi17:08:05

that is what I do also

pesterhazy17:08:49

if you use cider, you can set up a keyboard shortcut that does both (reload current buffer, run my.repl/refresh to recreate Stuart Sierra's component or whatever)

lambder17:08:54

so I require [org.danielsz/system "0.3.0"]

lambder17:08:00

and then what?

lambder17:08:16

I have redefined my boot task as follows:

lambder17:08:17

(deftask reset-backend [] (with-pre-wrap fileset (let [reset (resolve 'system.repl/reset)] (reset) fileset)))

lambder17:08:29

note using system.repl now

juhoteperi17:08:07

try using the task in system.boot

lambder17:08:30

java.lang.NullPointerException: boot.user/eval30066/fn/fn/fn boot.user4386639088127429058.clj: 19 adzerk.boot-cljs/eval368/fn/fn/fn boot_cljs.clj: 201

lambder17:08:43

which one?

lambder17:08:14

system.boot/system ?

lambder17:08:25

(system.boot/system :auto true) ?

lambder17:08:13

clojure.lang.ExceptionInfo: No such var: dir/scan-dirs data: {:file "system/boot.clj", :line 35} java.lang.RuntimeException: No such var: dir/scan-dirs

torgeir17:08:14

This working for anyone?

#!/usr/bin/env boot
(set-env! :dependencies '[[com.datomic/datomic-free "0.9.5390"]])
(require '[datomic.api :as d])

torgeir17:08:34

clojure.lang.ExceptionInfo: clojure/lang/Tuple

pesterhazy18:08:30

@torgeir: seeing the same issue

pesterhazy18:08:15

bug in latest datomic! 🙂

torgeir19:08:06

I’m seeing the same thing across all versions > 0.9.5359

anmonteiro20:08:34

@torgeir: @pesterhazy not a bug in Datomic. versions >= 0.9.5372 require Clojure 1.8

pesterhazy21:08:13

@anmonteiro: I tried adding Clojure 1.8 as an explicit dependency, didn't help

anmonteiro21:08:34

probably should be in boot.properties

anmonteiro21:08:00

I can definitely see the bug on Clojure 1.7 and not on 1.8

danielsz23:08:22

@lambder: A couple of suggestions to ease your experience with system.

danielsz23:08:47

The latest snapshot has validation baked-in, so you'll get better error messages.

danielsz23:08:43

So that would be 0.3.1-SNAPSHOT.

danielsz23:08:25

You don't need to define your own boot task to make it work, just include the system task in the pipeline. And configure it appropriately to your use case. If you use component, then that would be something like (system :sys #'dev-system :auto true). If you don't have components, that would be simply (system :auto true).

danielsz23:08:41

Your namespaces will be restarted and/or your system restarted when you save your source code, automatically.

danielsz23:08:44

Also, please look at the examples (tons of them) if you are stuck.

danielsz23:08:58

Good luck, and please let me know if you encounter difficulties.