Fork me on GitHub
#cider
<
2015-12-02
>
roberto02:12:09

is there a way to compile the entire project? I keep having to go to each namespace and compile individually.

bozhidar07:12:35

no, there’s not

bozhidar07:12:50

the idea is that people rarely work with all namespaces

bozhidar07:12:01

and if you compile just the stuff you need

malabarba10:12:31

@roberto but there are tools that eagerly load your entire project as a side effect. Clj-refactor is one of them.

robert-stuttaford10:12:34

there’s also good old lein check

robert-stuttaford10:12:02

we have an app we make a jar out of and deploy. i’d like to be able to connect to an nrepl service we have in this app and enjoy the full CIDER experience. however, cider is a lein plugin. we don’t use lein to run this app. how would i include the cider nrepl middleware in the jar?

malabarba11:12:23

Indeed, it's in the manual. 😉

roberto14:12:43

thanks, will look into clj-refactor. So the issue I’m having, is that when I open a project (normally a web app), and want to start it up via the repl, it fails because it says it can’t find various namespaces. I then have to go and compile each namespace individually. But once the server is up and running, I can just compile the stuff I need and it will be hot loaded.

benedek14:12:43

you might want to look into reloaded repl workflow and components. https://github.com/stuartsierra/component

benedek14:12:19

so you would start the repl. run reset which loads all your nses and starts up you webserver (and possible other related compnents of your system)

roberto14:12:19

I am using component

benedek14:12:26

ah do you? sorry

roberto14:12:27

that is exactly what I’m doing

benedek14:12:33

i may be misunderstanding then

roberto14:12:57

so, I start my day, boot up my laptop. Open emacs, open a web app.

roberto14:12:14

cider jack in, go to my repl.clj and run reset

roberto14:12:22

and boom, it fails to find some namespaces

roberto14:12:30

I have to go to each namespace, and compile

roberto14:12:33

then run reset, and it works

roberto14:12:39

and now I can compile functions on the fly

benedek14:12:53

does it run tools.namespace/refresh your reset impl?

roberto14:12:22

hmmm, no only tools.namespaces/set-init!

Lambda/Sierra14:12:38

set-init! is not part of tools.namespace

roberto14:12:56

I’m using reloaded.repl

roberto14:12:29

ah, I might need to refer reset

benedek14:12:01

indeed. it sounds like nothing runs refresh in your setup

roberto14:12:30

I was under the impression that reset would do that

benedek14:12:40

you should also see a list of reloaded namespaces in your repl most likely if refresh was run during reset

benedek14:12:12

depends on the reset impl i guess...

benedek14:12:30

indeed it does. but you said you needed to require reladed.repl’s reset?! so what kind of reset did you run before requiring it?

roberto14:12:53

yeah, I was requiring reset. I wasn’t requiring refresh

roberto14:12:48

ah, working now simple_smile Rebooting emacs for good measure

roberto14:12:55

this is my repl, btw:

(ns repl
  (:require [reloaded.repl :refer [system reset stop]]
            [clojure.tools.namespace.repl :refer [refresh]]
            [qfx-export.core :as q]
            [environ.core :refer [env]]))

(def config {:client-id         (env :client-id)
             :client-secret     (env :client-secret)
             :oauth-domain      (env :oauth-domain)
             :oauth-callback    (env :oauth-callback)
             :oauth-url         (env :oauth-url)
             :oauth-profile-url (env :oauth-profile-url)
             :oauth-token-url   (env :oauth-token-url)
             :port              (env :port)})

(reloaded.repl/set-init! #(q/create-system config))

benedek14:12:51

if this is reloaded.repl’s reset that should do the trick. you shouldn’t need to require refresh...

roberto14:12:03

yeah, but it isn’t doing the trick

roberto14:12:28

what it should do, and what it is actually doing don’t align.

benedek14:12:28

can you show your project.clj? what is your source-paths and/or your dev-source-paths and where does the file live for your repl namespace?

roberto14:12:45

and this is the repl.clj for this project:

(ns repl
  (:require [reloaded.repl :refer [system reset stop]]
            [clojure.tools.namespace.repl :refer [refresh]]
            [zoom-recordings.server.core :as s]
            [immuconf.config :as immuconf]))

(let [home-dir (System/getProperty "user.home")]
  (reloaded.repl/set-init! #(s/create-system (immuconf/load "resources/config.edn" 
                                                            (str home-dir "/.private/zoom-recordings/config.edn")))))

roberto14:12:04

repl.clj lives under a dev dir that is a sibling of the src dir.

roberto14:12:52

Example of calling (refresh :after 'reloaded.repl/resume) directly:

roberto14:12:07

:reloading (zoom-recordings.server.db.setup zoom-recordings.server.s3 zoom-recordings.server.db.recordings zoom-recordings.server.routes.core zoom-recordings.server.core zoom-recordings.server.db.db-test-component repl zoom-recordings.server.db.fixtures zoom-recordings.server.db.setup-tests zoom-recordings.server.db.recordings-test)
:error-while-loading zoom-recordings.server.db.setup
#error {
 :cause "No namespace: zoom-recordings.server.db.core"
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message "java.lang.Exception: No namespace: zoom-recordings.server.db.core, compiling:(zoom_recordings/server/db/setup.clj:1:1)"
   :at [clojure.lang.Compiler load "Compiler.java" 7239]}
  {:type java.lang.Exception
   :message "No namespace: zoom-recordings.server.db.core"
   :at [clojure.core$refer doInvoke "core.clj" 4080]}]
 :trace

roberto14:12:32

but it is there, and I have to go and manually compile that namespace

roberto14:12:10

upgrading to 0.2.1 of reloaded.repl. I just noticed I was using 0.2.0

benedek14:12:57

so I think (not 100% sure) there are two problems here: - your dev source-path points to ”dev” and according what you said your repl.clj is under "src/dev” - but more importantly repl.clj won’t get loaded automatically, user.clj would because: > You probably know that the Clojure REPL starts by default in the user namespace. In addition, if there is a file named user.clj at the root of the Java classpath, Clojure will load that file automatically when it starts.

roberto14:12:06

no, it is under dev

roberto14:12:16

dev is not under src

benedek14:12:26

misunderstood you then

benedek14:12:36

it could be the second point then

roberto14:12:13

the reason i placed it under a dev dir outside the main code, is because I don’t want it in production.

benedek14:12:26

that is the good approach

roberto14:12:43

so, I should just replicated the namespace inside dev ?

roberto14:12:47

will try that

benedek14:12:39

you should have an user.clj under dev not repl.clj i think

benedek14:12:50

because user.clj would be autoloaded (see the quote above)

benedek14:12:57

your problem may be that your repl.clj is not autoloaded

roberto14:12:12

hmmmm, changing to user.clj doesn’t work either. But I think you are right. My repl.clj or user.clj isn’t being loaded.

roberto14:12:58

I’m probably placing user.clj in the wrong location

roberto15:12:01

I got it to work after reading through clojure.tools.namespace

roberto15:12:28

so, I had :main defined in my dev lein profile.

roberto15:12:37

which was triggering AOT

Lambda/Sierra15:12:14

When in doubt, it's AOT.

roberto15:12:33

sorry for bothering you guys. I should have read the docs more carefully. The docs for tools that abstract tools.namespace assume we know this.

roberto15:12:04

btw, @stuartsierra thank you for the Readme in tools.namespace

Lambda/Sierra15:12:28

You're welcome! Glad to hear it was helpful.

benedek15:12:01

uh, nice 👍

sdroadie21:12:10

Hey all. I updated Cider (accidentally) to 0.10.0-SNAPSHOT. It wants an cider/cider-nrepl 0.10.0-SNAPSHOT, which I also installed, and nrepl 0.12.0 or later. I have this installed, and Leiningen sees it, but when I open a Cider repl, it still sees the old version. Can anyone help?