Fork me on GitHub
#cider
<
2018-07-24
>
plexus12:07:31

I've been getting this thing lately where when I try to evaluate a form all I get is a complaint in the minibuffer saying "Namespace Not Found"

bozhidar12:07:23

Any repro steps for this?

plexus12:07:31

It seems in this case it started when I created a new namespace, it's there, it's saved, it's on the filesystem in the right place. I can eval the ns form, but anything else it won't do.

bozhidar12:07:04

load-file doesn’t work?

plexus12:07:37

where would I do that? (load-file "full-path.clj") from the REPL?

plexus12:07:32

tried this with two namespaces, for one doing load-file cleared the problem, for the other it doesn't. they both contain nothing but an empty (ns) form

plexus13:07:10

how do I enable the thing where I can see all nREPL messages going back and forth?

dpsutton13:07:32

nrepl-toggle-message-logging

dpsutton13:07:48

that message is in the response. so for sure check what's going over the wire

plexus13:07:36

ok this is interesting

plexus13:07:40

(-->
  id         "35"
  op         "eval"
  session    "8e6e275a-6335-4ead-9e78-827b408adbd4"
  time-stamp "2018-07-24 15:07:34.188062715"
  code       "(+ 1 1)
"
  column     1
  file       "/home/arne/Nextjournal/nextjournal/journal/server/env/dev/server/figwheel/api.clj"
  line       2
  ns         "server.env.dev.server.figwheel.api"
)
(<--
  id         "35"
  session    "8e6e275a-6335-4ead-9e78-827b408adbd4"
  time-stamp "2018-07-24 15:07:34.207152917"
  status     ("namespace-not-found" "done" "error")
)

plexus13:07:57

(ns server.figwheel.api)

plexus13:07:45

when that file was first created it automatically got an ns form that read (ns server.env.dev.server.figwheel.api) (I guess clj-refactor does that)

plexus13:07:11

somehow CIDER thinks it still has that namespace, even though the ns form has been updated, and even though I restarted nREPL (!)

dpsutton13:07:48

did you kill the buffer?

dpsutton13:07:05

there's a buffer local version to hold that value apparently

bozhidar13:07:33

@dpsutton I don’t think we have a buffer-local for for the source buffers.

bozhidar13:07:53

There’s a bit of logic to watch the ns for modifications even.

plexus13:07:09

reloading the buffer does clear it up

dpsutton13:07:44

(setq-local cider-buffer-ns ns) . I'm not sure how it gets set in code buffers but there is some state out there

bozhidar13:07:50

Interesting. Guess really some buffer-local ns var must have been set, but those were never intended to be used with source files.

dpsutton13:07:10

yeah i've never seen that before

dpsutton13:07:28

@plexus do you override the start ns from user to something else?

plexus13:07:22

yes, we do, we have a server.repl namespace

dpsutton13:07:39

and is this that namespace or is it unrelated?

plexus13:07:48

no, that's unrelated

dpsutton13:07:18

well i'm at a loss then. if you can give some steps to repro from a new project i can look into it but if its not worth your time i understand that as well

plexus13:07:53

I'll see if it comes up again, ran into this three times in two days on three separate projects so not unlikely

pablore13:07:42

Hi, just updated Cider this morning an am getting this error

bozhidar13:07:22

@pablore You’re getting it from clj-refactor.el and refactor-nrepl (which was recently updated).

bozhidar13:07:30

Guess you’ll have to disable it.

pablore13:07:02

How do I do disable it? I’m using spacemacs

bozhidar13:07:23

Read CIDER’s FAQ/Troubleshooting.

bozhidar13:07:30

There was something about this there.

jumar14:07:16

@pablore I got the same error when using Java 1.10. I downgraded to java 1.8 and can still use clj-refactor.

pablore18:07:52

Is there anyway I can set my JAVA_HOME from inside emacs?

jumar19:07:47

@pablore you could use setenv but I'd suggest to configure proper java system wide. I use jEnv (http://www.jenv.be/) for that.

apt14:07:44

Hey, does anyone know how to programatically evaluate something with cider and show the result in a window in Emacs? This is what I have done: http://ix.io/1igi . I think it actually works, except that I don't know how to get the output in a window in a decent way (I could insert the result into a buffer, load clojure mode and indent it, but I'm sure there's a better way). Also, what's a good resource for learning Cider internals?

dpsutton14:07:58

@andre.peric there's the manual at https://cider.readthedocs.io/en/latest/ and i have some internal walkthroughs at http://hackingcider.com/

👍 4
apt14:07:34

Thanks, hackingcider seems to be exactly what I want

dpsutton14:07:35

awesome! when you learn things make an overview of what was useful and submit a PR!

👍 4
martinklepsch15:07:33

has anyone tried hacking on clojure.spec with Cider? I can’t get it to work for some very weird reasons:

#object[clojure.spec.alpha$and_spec_impl$reify__2173 0xf14b48f
   "clojure.spec.alpha$and_spec_impl$reify__2173@f14b48f"] is not a
   fn, expected predicate fn
I did create a deps.edn file with the appropriate :paths

martinklepsch15:07:16

When loading clojure.spec.alpha it seems the c/and in line 81 is pointing to spec’s and for some reason …

bozhidar15:07:51

I haven’t used spec much, but generally CIDER shouldn’t affect spec usage at all.

martinklepsch16:07:06

It’s not really about spec usage but rather about hacking on Spec itself — as in running cider in this repo: https://github.com/clojure/spec.alpha/

bozhidar16:07:08

It should be a project like any other. Not sure what can special to it.

martinklepsch16:07:22

I’m also not sure what could be different which is why I came here to ask if anyone else tried it 😄

dominicm16:07:21

doesn't cider depend on spec in some way?

bozhidar16:07:46

No, it doesn’t.

dominicm17:07:31

It does, for the spec Explorer?

dominicm17:07:12

I don't think that's a dependency which is inlined though.

bozhidar17:07:14

It’s not a project dependency at all - we check if spec is present, otherwise we just stub it.

bozhidar17:07:52

(ns orchard.spec
  (:require [clojure.walk :as walk]
            [clojure.pprint :as pp]
            [clojure.string :as str]))

(defmacro spec [fname & args]
  `(when-let [f# (or (resolve (symbol "clojure.spec.alpha" ~fname))
                     (resolve (symbol "clojure.spec" ~fname)))]
     (f# ~@args)))

(defmacro spec-gen [fname & args]
  `(when-let [f# (or (resolve (symbol "clojure.spec.gen.alpha" ~fname))
                     (resolve (symbol "clojure.spec.gen" ~fname)))]
     (f# ~@args)))

bozhidar17:07:37

So, there’s basically nothing to inline - if spec’s there it will be resolved, otherwise it won’t be.

bozhidar17:07:59

Not sure how this can cause the problems @martinklepsch mentioned.

jumar20:07:28

@martinklepsch I tried it with leiningen and the same error. It seems that the key setting is -Dclojure.spec.skip-macros=true: https://github.com/clojure/spec.alpha/blob/master/pom.xml#L73 With it I can at least eval the alpha namespace.

jumar20:07:48

Here's my project.clj:

(defproject clojure-spec-alpha "0.2.169-SNAPSHOT"
  :description "Clojure spec"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[org.clojure/clojure "1.10.0-alpha4"]
                 [org.clojure/test.check "0.10.0-alpha2"]]
  :source-paths ["src/main/clojure"]
  :java-source-paths ["src/java"]
  :target-path "target/%s"
  :jvm-opts ["-Dclojure.spec.skip-macros=true"])

martinklepsch20:07:19

Interesting — thanks for the pointer!