Fork me on GitHub
#boot
<
2016-07-07
>
timothypratley00:07:10

@nha this is the best I could come up with:

(deftask public []
  (comp (production)
        (build)
        (sift :invert true :include #{#"js/app.out" #"js/app.cljs.edn"})
        (target :dir #{"public"})))
I couldn't find a way to explicitly choose everything from a resources/public that worked for deployment, dev serving and compiling (I could get them all working individually, but not together)... at least the above avoids deploying all the intermediary cljs output. I would love to know if you find a way to isolate the deployable assets from the rest of the resources, because using an explicit list is tedious.

nha00:07:24

@timothypratley: Thanks ! I will have a look tomorrow and let you know šŸ™‚

nha00:07:52

(I have nothing better than that for now - I was running bash commands right now šŸ˜• )

luke03:07:04

Is there a straightforward way to run a boot process, inside another boot process, with a completely different environment, without damaging/altering the parent environment? The use case is for building sub-projects of my main project, that live in their own directories with their own build.boot files, etc. The best solution I have right now is shelling out a full subprocess, which works, but that seems a bit wasteful.

richiardiandrea04:07:53

@luke I would look into boot.pot for classpath isolation, band even more in boot parallel for running completely separate boot envs for your tasks (if you have any question about the latter, feel free to ping me)

cycle33709:07:47

hello! i'm trying to run an immutant webserver with boot and configured a task that simply starts a hello world page. problem is boot keeps killing the app and when I include (boot (wait)) it just son't start at all. any pointers ?!

martinklepsch10:07:54

@avabinary: you you launch this from a REPL what do your boot invocations look like?

cycle33710:07:22

hi @martinklepsch, my task is this

cycle33710:07:25

(deftask run [a args ARG [str] "the arguments for the application."] (require '[myapp.core :as myapp]) (with-pass-thru _ (resolve 'myapp/-main)))

cycle33710:07:29

i have an atom called http-server

cycle33710:07:34

and I do this in my main

cycle33710:07:36

(defn -main [& args] (.addShutdownHook (Runtime/getRuntime) (Thread. #(do (immutant/stop @http-server) (shutdown-agents)))) (reset! http-server (immutant/run app :host "0.0.0.0" :port 8080)) (timbre/info "server started on port:" (:port @http-server)) )

cycle33710:07:15

I don't have any args bound at the moment for my main

cycle33710:07:43

the app function is just :status 200 and :body hello world

martinklepsch10:07:17

consider using triple backticks for code `

martinklepsch10:07:33

and how do you start this?

cycle33710:07:49

i just boot run the task

martinklepsch10:07:16

so you type boot run into a terminal and hit enter?

martinklepsch10:07:28

have you tried boot run wait?

cycle33710:07:12

it just hangs

martinklepsch10:07:32

and boot run exits right? do any of these two print the timbre log message?

cycle33710:07:59

other tasks that I've defined work fine (like migratus,etc.)

martinklepsch10:07:20

nope to which question @avabinary? šŸ™‚

cycle33710:07:59

oh, sorry. i meant none of them print any timbre logs,

boot run
just exits and
boot run wait
hangs

martinklepsch10:07:57

duh, (resolve 'x/y) does not call the function y šŸ™‚

martinklepsch10:07:13

try ((resolve 'myapp/-main))

cycle33710:07:53

thank you, now it works fine.

cycle33710:07:00

devil's in the details ...

luke11:07:41

@richiardiandrea using pods does seem like the way to go, but what I canā€™t find out is how to initialize the pod with an ā€œinnerā€ instance of boot reading from itā€™s own build.boot and a different working directory.

martinklepsch11:07:30

@luke: pods aren't really made for having their own boot pipeline. If you want to run tasks you need boot parallel I think

martinklepsch11:07:33

@luke: maybe it helps if you outline the kind of use-case you have in mind etc

cycle33711:07:08

does anyone know where to get an example of a development and production profile for boot ? in the boot-clj wiki it's mainly about system environments

martinklepsch11:07:12

@avabinary: if you run lein new tenzing it will have basic dev/prod profiles. The wiki also has this https://github.com/boot-clj/boot/wiki/Boot-for-Leiningen-Users

cycle33711:07:09

ok, I'll have a look, thanks @martinklepsch

dominicm11:07:14

boot -d seancorfield/boot-new new -t tenzing -n myapp

martinklepsch11:07:27

well, yeah šŸ™‚

luke11:07:30

@martinklepsch: Basically I want to build some other projects at arbitrary locations, but without starting a whole new JVM.

luke11:07:02

parallel/runboot looks like exactly what I want except it doesnā€™t seem to offer a way to redefine the ā€œcurrentā€ directory.

martinklepsch11:07:23

yeah, then you need multiple pipelines which is what boot parallel enables

cycle33711:07:19

way the go keeping things lein free :)))

martinklepsch11:07:46

@luke: by passing args you can set different source/resource dirs but this doesn't tie in nicely with having existing build.boot files..

luke11:07:58

yeah, kind of want to be able to run either standalone or driven from a parent boot process

martinklepsch11:07:03

@luke: maybe you could circumvent this issue by having an edn file in each project that you read upfront to determine args

luke11:07:20

shelling out and creating a whole subprocess actually does exactly what I want, just tends to add some overhead

martinklepsch11:07:44

In any case I'm not very familiar with this so we should probably wait for @richiardiandrea to shed some light on this šŸ™‚

luke11:07:54

Cool, thanks for your help šŸ™‚

richiardiandrea14:07:49

Yeah Martin is right, boot in boot still ties you to the original jvm, but that can be your parent process. What it does not do at the moment is to read a completely new env from somewhere...this is basically a small patch to add but probably does not allow it to work for your use case

martinklepsch14:07:05

How about passing an env-map option for the runboot task that will be handed to set-env! ? This way you can read that kind of stuff from a edn file in the individual projects

martinklepsch14:07:37

The build.boot files on those projects should then also read this information from the edn file

richiardiandrea15:07:55

I reckon it is the simplest way ^ too bad we don't have a boot only solution though

richiardiandrea15:07:10

I mean a clean one

richiardiandrea15:07:41

I wanted to have customizable envs for boot.parallel , maybe combined with the env dynamic var

richiardiandrea15:07:56

Just need time to do it šŸ˜‰

martinklepsch17:07:40

I find this approach pretty clean actually, it's a pretty special scenario and requires some extra work but given the requirements it seems almost appropriate

flyboarder17:07:36

Hey is there a flag for clearing a project cache folder?

flyboarder17:07:54

I just wiped the .boot/cache/ folder but I was wondering if there is a flag i didnā€™t see?

martinklepsch17:07:22

there's no flag afaik and very rarely you should need to do this (except you want to free up space)

seancorfield17:07:37

[ANN] boot-expectations 1.0.10 is available. Adds expecting task to make it easier to work with your Expectations tests in a REPL: https://clojars.org/seancorfield/boot-expectations

richiardiandrea22:07:28

So this is an interesting thing, I have two pod, one with backend deps and one with frontend compiling cljs

richiardiandrea22:07:44

now I have a file that I want to share, this file is a cljc

richiardiandrea22:07:16

I have a #?(:clj (:require [clj-time.core :as t])) reaquire

richiardiandrea22:07:25

that I want to be visible only in the backend

richiardiandrea22:07:11

unfortunately, there is no way to tell the cljs compiler that this is not a "cljs macro" and throw an error because clj-time is not on the path

richiardiandrea22:07:38

it can never happen with lein, there is no classpath isolation, but in boot, with pods, it can

martinklepsch22:07:14

If this only ends up in the clj file why would the compiler think it's a cljs macro?

martinklepsch22:07:32

If it's not required in the cljs file it shouldn't matter no?

martinklepsch23:07:31

In general can you reference namespaces in irrelevant reader conditional branches that are not on the classpath? @richiardiandrea

richiardiandrea23:07:25

my understanding is that every #?(:clj ...) is treated as macro in cljs

richiardiandrea23:07:02

but in my cljs pod I don't have the dep

richiardiandrea23:07:24

so it is required I guess

richiardiandrea23:07:51

adzerk.boot-cljs.impl/reload-macros!/invokeStatic       impl.clj:  108
                      adzerk.boot-cljs.impl/reload-macros!       impl.clj:  100
                                                       ...                     
                           clojure.core/apply/invokeStatic       core.clj:  646
                                        clojure.core/apply       core.clj:  641
                                     boot.pod/eval-fn-call        pod.clj:  328
                                         boot.pod/call-in*        pod.clj:  379
                                                       ...                     
                                         boot.pod/call-in*        pod.clj:  382
                     adzerk.boot-cljs/compile/invokeStatic  boot_cljs.clj:   66
                                  adzerk.boot-cljs/compile  boot_cljs.clj:   59
                             adzerk.boot-cljs/compile-1/fn  boot_cljs.clj:  126
                       clojure.core/binding-conveyor-fn/fn       core.clj: 1938

richiardiandrea23:07:06

the above ends up causing the require (and the error)

juhoteperi23:07:33

Hmm, yeah, boot-cljs will require (reload) any clj/cljc "macro" namespaces

juhoteperi23:07:45

But it should only do that for namespaces that are already loaded

juhoteperi23:07:48

are you using cljs macros at all? maybe some macro ns requires this ns

richiardiandrea23:07:20

that namespace is required, because I need cljs stuff from it, but it does not contain any macro

juhoteperi23:07:09

that's not quite what I meant

richiardiandrea23:07:39

kk maybe I did not understand then šŸ˜„

juhoteperi23:07:06

Reload-macros requires any namespaces in Clojure context that are already loaded in Clojure context

juhoteperi23:07:41

And that should only be caused by :require-macros

juhoteperi23:07:08

Doesn't really matter if the file defines any macros

juhoteperi23:07:39

If a Cljs namespace does require-macros, the macro namespace is loaded in Clojure context and all it's dependencies are loaded in Clojure context

richiardiandrea23:07:40

ok now it is clear, but I think I never require it using require-macros, nor some dependent is...but I am double checking

juhoteperi23:07:19

Could be something else, but I'm yet to hit problems with the reload-macros! logic

juhoteperi23:07:58

I'm in fact quite surprised how well the approach has worked seeing how simple it is

richiardiandrea23:07:22

i can share the file...maybe it is better to create a smaller repro repo

richiardiandrea23:07:05

it starts like this:

(ns my-ns.events
  #?@(:clj ((:require [clj-time.core :as t])
            (:refer-clojure :exclude [type]))
      :cljs ((:refer-clojure :exclude [type]))))

micha23:07:22

@richiardiandrea: i don't think the reader conditionals are treated as macros in the cljs compiler, because they're expanded in the reader...the cljs compiler can't see them

micha23:07:05

is that not correct?

richiardiandrea23:07:10

true that I agree, this looks like a problem in the reloading part...but not sure, let me work on a repro repo first

richiardiandrea23:07:53

:clj clauses are used for declaring macros

richiardiandrea23:07:09

in cljc files no?

juhoteperi23:07:11

You could enable debug prints and I think this would provide information about which namespaces are loaded in Clojure side: https://github.com/adzerk-oss/boot-cljs/blob/master/src/adzerk/boot_cljs/impl.clj#L107

micha23:07:16

yes because the macros are created by requiring the namespace in clojure

micha23:07:28

so the clojure compiler only sees the :clj ones

micha23:07:32

and not the :cljs ones

richiardiandrea23:07:47

@juhoteperi I enabled -verbose and I see:

Reload macro ns: booma.data-format
clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could not locate cognitect/transit__init.class or cognitect/transit.clj on classpath., compiling:(booma/data_format.cljc:1:1)
          java.io.FileNotFoundException: Could not locate cognitect/transit__init.class or cognitect/transit.clj on classpath.

richiardiandrea23:07:16

this does not happen in a tenzing project so I guess I have some difference from the standard config

richiardiandrea23:07:48

it looks for a clj file that cannot be there because I have transit-cljs not transit-clj on the classpath

richiardiandrea23:07:43

this is a different cljc from the above, so this happens for all the cljc that require something as clj

richiardiandrea23:07:52

(ns booma.data-format
  (:require [cognitect.transit :as transit])
  #?(:clj (:import [org.joda.time DateTime ReadableInstant])))