Fork me on GitHub
#cider
<
2015-12-26
>
crocket09:12:05

When I invoke cider-cljs-lein-repl, hello-world.core is not loaded to the REPL automatically. I have to load it manually. How can I have it done automatically?

bozhidar10:12:06

cider never loads namespaces automatically

crocket10:12:58

What does?

crocket10:12:24

When I launch a clojure repl, the current source file is automatically loaded.

crocket10:12:02

I opened core.clj and invoked cider-jack-in. The launched cider repl start on core

crocket10:12:16

The core namespace is already loaded.

crocket10:12:24

Why does it not happen on CLJS repl?

crocket10:12:16

Actually, the whole project is already laded.

bozhidar10:12:16

it’s not cider for sure

bozhidar10:12:26

maybe you have some lein setting to load some ns

bozhidar10:12:37

are you using clj-refactor?

bozhidar10:12:52

it evaluated all the namespaces to build an AST for them

bozhidar10:12:57

but it doesn’t work on cljs

crocket10:12:09

My project.clj

crocket10:12:26

(defproject clj-ddns-client "1.3.5"
  :description "It updates DDNS entries of various DDNS providers."
  :url ""
  :license {:name "Mozilla Public License 2.0"
            :url ""
            :year 2015
            :key "mpl-2.0"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [clj-time "0.10.0"]
                 [jarohen/chime "0.1.6"]
                 [clj-http "1.1.2"]
                 ;; logging
                 [spootnik/unilog "0.7.8"]
                 [org.clojure/tools.logging "0.3.1"]
                 ;; cli
                 [org.clojure/tools.cli "0.3.1"]]
  :main ^:skip-aot clj-ddns-client.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

bozhidar10:12:28

when you said all namespaces

bozhidar10:12:35

I’m pretty sure you’re using clj-refactor...

bozhidar10:12:09

it needs really big warnings, as half the users have no idea it loads their code

crocket10:12:18

My ~/.lein/profiles.clj

crocket10:12:21

{:user {:plugins [[cider/cider-nrepl "0.10.0"]
                  [lein-license "0.1.3"]]
        :dependencies [[org.clojure/tools.nrepl "0.2.12"]]}}

bozhidar10:12:43

hmm, that’s odd

bozhidar10:12:53

well, cider really doesn’t load anything by itself

bozhidar10:12:57

it has to be something else

crocket10:12:23

Maybe, it's nrepl?

bozhidar10:12:33

p.s. you want cider’s deps in the :repl profile, not the :user

bozhidar10:12:41

no, nREPL doesn’t do anything like this either

bozhidar10:12:51

clj-refactor is the only tool I know which does this

bozhidar10:12:58

and you’re saying you don’t use it

bozhidar10:12:03

so this is a mystery

crocket10:12:57

Are you using emacs?

crocket10:12:56

@bozhidar: Do you have to explicitly press C-c C-l for every namespace you open in emacs?

crocket10:12:10

Or, are namespaces loaded automatically once on REPL startup?

bozhidar10:12:56

I’m the author of CIDER, I guess I’m using Emacs 😉

bozhidar10:12:12

(and I’m reasonably sure I know how it works)

bozhidar10:12:42

the namespaces have to loaded with C-c C-k most of the time

bozhidar10:12:52

if you evaluate code in a namespace that hasn’t been compiled

bozhidar10:12:29

cider will auto-evaluate its (first) ns declaration to create some ns context for the code evaluation

bozhidar10:12:17

loaded nses automatically is a very bad idea, as some namespaces have code that does something with side-effects

crocket10:12:18

If you open core.clj and press C-c M-j, is core.clj loaded automatically on REPL startup?

crocket10:12:46

Somehow, functions and variables on core.clj are available on my cider REPL from the beginning.

bozhidar10:12:48

no, core.clj is not loaded automatically

bozhidar10:12:59

whatever is doing this is not CIDER and is not nREPL

bozhidar10:12:07

of that I’m 100% certain

crocket10:12:30

Emacs version?

crocket10:12:38

Mine is 24.5.1

bozhidar10:12:40

it’s irrelevant

bozhidar10:12:01

cider works exactly the same on every supported Emacs version

bozhidar10:12:17

must be something else

crocket10:12:45

By the way, do you know how to launch a figwheel in nREPL conveniently in emacs?

crocket10:12:17

For now, I have to launch a clojure repl, start figwheel, and start figwheel cljs-repl in the clojure REPL.

crocket10:12:18

Perhaps, it is lein-repl.

crocket11:12:54

@bozhidar: If :main in project.clj is set, it is loaded on cider REPL on startup.

crocket11:12:01

The main namespace is opened and loaded on cider REPL automatically.

codemartin12:12:32

@crocket: Many many moons ago I ran a function like this

(defun cider-figwheel-repl ()
  (interactive)
  (save-some-buffers)
  (with-current-buffer (cider-current-repl-buffer)
    (goto-char (point-max))
    (insert "(require 'figwheel-sidecar.repl-api)
             (figwheel-sidecar.repl-api/cljs-repl)")
    (cider-repl-return)))
It might be useful for you to hook into figwheel, but I hardly remember when I added it to my emacs.d. Hope it is what you wondered about, sorry otherwise

benedek12:12:16

@crocket this is a leiningen feature tho I think. if you start a repl from command line with lein repl you should see the same

crocket12:12:42

Is this wrong? ~/.lein/profiles.clj

{:user {:plugins [[lein-license "0.1.3"]]}
 :repl {:plugins [[cider/cider-nrepl "0.10.0"]]
        :dependencies [[org.clojure/tools.nrepl "0.2.12"]]}}

crocket13:12:59

Somehow, :repl is ignored.

malabarba19:12:18

@croket about figwheel. There's a pretty straightforward tutorial on that

malabarba19:12:25

Just Google cider figwheel