This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-20
Channels
- # bangalore-clj (3)
- # beginners (30)
- # boot (117)
- # braid-chat (6)
- # carry (9)
- # cider (6)
- # clara (11)
- # cljs-dev (28)
- # cljsrn (12)
- # clojars (2)
- # clojure (114)
- # clojure-austin (2)
- # clojure-dev (1)
- # clojure-dusseldorf (1)
- # clojure-greece (47)
- # clojure-italy (5)
- # clojure-russia (79)
- # clojure-spec (121)
- # clojure-uk (133)
- # clojurescript (92)
- # community-development (67)
- # copenhagen-clojurians (1)
- # core-async (25)
- # cursive (67)
- # datascript (1)
- # datomic (34)
- # devcards (24)
- # emacs (8)
- # funcool (71)
- # juxt (1)
- # keechma (2)
- # lein-figwheel (6)
- # luminus (8)
- # mount (17)
- # om (135)
- # om-next (13)
- # onyx (147)
- # pedestal (11)
- # planck (7)
- # re-frame (42)
- # reagent (86)
- # rum (11)
- # specter (6)
- # testing (6)
- # untangled (1)
- # vim (6)
- # yada (24)
I'm trying to prefetch some dependencies for my project from Maven/Clojars, and save them into the Docker image.
However, I don't want to keep them directly in /root/.m2/
because I then plan to mount host's .m2/
on top of the image.
I suppose that the solution would be to copy /root/.m2
to say /root/.m2cache
, and then specify file:///root/.m2cache
as one of the :repositories
in /root/.boot/profile.boot
.
Should this be enough? I tried doing all this, and then deleted /root/.m2/
, but Boot still downloads the dependencies from Maven and Clojars instead of copying the from the .m2cached
.
@alexyakushev I might guess that it's done in priority order.
There is also: BOOT_LOCAL_REPO The local Maven repo path (~/.m2/repository).
@juhoteperi I don't think that would work because he wants both .m2
and .m2cache
@dominicm: I thought it was priorities, but then I tried completely removing other repositories (value instead of conj
) and it is still the same
Odd, I wouldn't expect boot to be able to grab from maven when repositories is unset?
boot show -e
shows:
:repositories
[["m2-prefetched" {:url "file:///root/.m2_prefetched/repository/"}]]
There are two problems, actually. First is that many dependencies are still downloaded from
and from Clojars. But eventually, it starts grabbing some from my local repo, and then at some point it fails with:
Exception in thread "FileRepositoryConnector-1" java.lang.IllegalArgumentException: number of transferred bytes cannot be negative
At the very least, I wanted to figure out if I'm moving in the right direction at all. Can a local repository be used like this, without any additional "wagons"? Also, does Boot at all depend on Maven's configuration?
@alexyakushev https://github.com/cemerick/pomegranate/blob/e44f45fa3abc29dbc0ab88f98b9bbbada7819128/src/main/clojure/cemerick/pomegranate/aether.clj#L25 I think so
Or maybe not, given that a special thing is made for it: https://github.com/cemerick/pomegranate/blob/e44f45fa3abc29dbc0ab88f98b9bbbada7819128/src/main/clojure/cemerick/pomegranate/aether.clj#L128-L131
@alexyakushev Looks like you're hitting https://github.com/cemerick/pomegranate/issues/71
@alexyakushev report back if you remember, I'm always interested to know how these things turn out!
Howdy y'all. The basic Buddy auth example for JWE tokens doesn't seem to be working for me. I'm using Boot and System with Sente to send the POST request to login, and it returns success. But I always get unauthorized
when I check with buddy/authenticated?
I'm guessing the problem is that Buddy only checks the :identity
key in the Ring map, but the example puts the token elsewhere? Ahdunno, tried this for a few hours yesterday.
I kind of want to use the Buddy middleware because I figure it will easily tell if the token has expired.
@coyotespike maybe better asked in #clojure or #funcool ?
Yeah, I wasn't very sure where to ask this one - I'll try #funcool and then #clojure, thanks
🙂 didn't know we had a funcool channel
Is there a way to disable namespace pretty printing?
Boot is hot-reloading my DevCards (yay!!) but not my regular page .
If my dev
task is just this, then nothing really happens:
(deftask dev
"Run a restartable system in the Repl"
[]
(comp
(environ :env config)
(watch :verbose true)
(system :sys #'dev-system :auto true :files ["handler.clj" "services.clj"])
(reload)
(cljs :source-map true
:compiler-options {:devcards true})
(repl :server true)
(speak)))
If I make it look like this, then it *does hot reload*, but I get target container is not a DOM element
:
(deftask development []
(task-options! cljs {:optimizations :none
:unified-mode true
:source-map true
:compiler-options {:devcards true}}
reload {:on-jsload 'holy-grail.core/app})
identity)
(deftask dev
"Run a restartable system in the Repl"
[]
(comp
(development)
(environ :env config)
(watch :verbose true)
(system :sys #'dev-system :auto true :files ["handler.clj" "services.clj"])
(reload)
(cljs)
(repl :server true)
(speak)))
Seems like I'm really close!
Hmmm...I figured out the source of the error, nothing to do with build.boot
Instead it's Secretary.
For some reason this function with reagent messes with Boot's reload:
(defn hook-browser-navigation! []
(doto (History.)
(events/listen
HistoryEventType/NAVIGATE
(fn [event]
(secretary/dispatch! (.-token event))))
(.setEnabled true)))
@coyotespike You running that on every reload?
@dominicm Yes, I put it in my init
function
Probably unrelated. But that might cause you to have multiple listeners to the history.
hmmm interesting
I think you might be right - at least, it looks like as a var it will hook in history, and since it's not in the init function it's not causing an error
That did fix the reloading, thanks for your input @dominicm 😄.....now to get History working again...
I think this bit is still Boot-related...after I update the page and the browser reloads, I'm able to navigate, just get the error:
history.js:899 Uncaught TypeError: Cannot set property 'value' of null
everything works so I can ignore it, but it's odd.
Before a hot-reload, a navigation event does not trigger that error.
that hook-browser-navigation function will add more history event handlers every time it is called
Thanks @micha, that's really good to know
I now have history like:
(def history
(doto (History.)
(events/listen EventType.NAVIGATE
(fn [event] (secretary/dispatch! (.-token event))))
(.setEnabled true)))
And init function like:
(defn app
"Configure and bootstrap the application."
[]
(dispatch-sync [:initialise-db])
(when (identical? config/production false)
;; -- Debugging aids ----------------------------------------------------------
(devtools/install!) ;; we love
(enable-console-print!)) ;; so println writes to console.log
(reagent/render [todo-app] (.getElementById js/document "container"))
(sente/start-chsk-router! ch-chsk event-msg-handler*))
Bad weirdness gone without history as a function, just errors in console after hot reload. Back button works, etc.
i'm all ears
so one solution is to make sure you always remove any existing handlers before adding a new one
but since it now is associated with a var, foo
, the definterval
macro actually emits code that removes any existing interval named foo
goog.events/listen returns a key which can be used to remove the listener using goog.events/unlisten
you could add a property to the history object that has some handle you can use to remove the previous event
huh...that's really interesting.
you can save the value to a atom and clear the previous listener before adding new
if you save it to the History object itself then you avoid any interaction with code reloading
* goog.events/unlistenByKey
because if the History object itself is destroyed then you don't care about events on it
I'm a little surprised other people haven't hit this issue with Boot and Secretary/goog.events...that's an interesting solution
(when-let [key (aget js/History "rmMyEvent")]
(goog/unlisten key))
(set! (.-rmMyEvent js/History) (goog/listen ...))
I mean, to the degree that macros are straightforward 😉
(defmacro defhandler
[name obj event handler]
(let [prop (str "_defhandler_" name)]
`(let [obj# ~obj]
(when-let [k# (aget obj# ~prop)]
(events/unlisten k#))
(aset obj# ~prop (events/listen obj# ~event ~handler))
obj#)))
Most apps need only one such event listener and then a macro is overkill
otherwise it could be that the code that does the unhooking itself gets reloaded and you lose your state
with messy things like patching code in place i think it makes sense to spend some time to get it right up front
because there are few things i get more annoyed at than debugging race conditions or state stuff like this
simples thing is to just keep the listener key in atom which is defonce'd and there is never problems
defonce
tbh I'm not quite sure what usage would look like
I'll play around with it
Thanks guys!
the second parameter is event type
(def history
(events/listen js/History EventType.NAVIGATE
(fn [event] (secretary/dispatch! (.-token event))))
(.setEnabled true)))
Solution used by several project templates is to just not call this code after reload
Like put it in another file and sift
it out?
just don't call it in init function
or whatever is the function that called on every function
oh, yeah, I took it out of the init function, and now it hot-reloads without gross errors
It is now just a var, unmentioned in my init file, like this:
(def history
(doto (History.)
(events/listen EventType.NAVIGATE
(fn [event] (secretary/dispatch! (.-token event))))
(.setEnabled true)))
that will still be re-evaluated when that file changes
This hot-reloads, and navigates. After a hot-reload, it just starts complaining at me.
but you could change that to defonce
and it won't be re-evaluated
you're completely right!
Errors magically gone 😄
Thanks!