Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace not found error in cider 0.9.0 #1139

Closed
ogis-hashi opened this issue Jun 17, 2015 · 11 comments
Closed

Namespace not found error in cider 0.9.0 #1139

ogis-hashi opened this issue Jun 17, 2015 · 11 comments

Comments

@ogis-hashi
Copy link

I am facing a "Namespace not found" error when I evaluate (ns namespace)
after updating cider 0.9.0 from 0.9.0-SNAPSHOT this morning.

It occurred even if in a new project by 'lein new dummy'.

$ tree .
├── LICENSE
├── README.md
├── doc
│   └── intro.md
├── project.clj
├── resources
├── src
│   └── dummy
│       ├── #core.clj#
│       └── core.clj
├── target
│   ├── classes
│   │   └── META-INF
│   │       └── maven
│   │           └── dummy
│   │               └── dummy
│   │                   └── pom.properties
│   ├── repl-port
│   └── stale
│       └── extract-native.dependencies
└── test
    └── dummy
        └── core_test.clj

13 directories, 10 files
$ 
; CIDER 0.9.0 (package: 20150616.1226) (Java 1.8.0_40, Clojure 1.6.0, nREPL 0.2.10)
user> 

project.clj is very simple like this:

(defproject dummy "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]])

my ~/.lein/projects.cls as follows:

{:user {:plugins [
                  [lein-try "0.4.3"]
                  [lein-ancient "0.6.4" :exclusions [org.clojure/core.cache]]
                  [lein-bikeshed "0.2.0"]
                  [lein-ritz "0.7.0"]
                  [lein-marginalia "0.8.0"]
                  [http-kit/lein-template "1.0.0-SNAPSHOT"]
                  [cider/cider-nrepl "0.9.0"]
                  [cljs-complete "0.1.1"]
                  [lein-immutant "2.0.0"]
                  [lein-droid "0.3.0-beta4"]
                  [lein-hadoop-cluster "0.1.2"]
                  [jonase/eastwood "0.2.1"]
                  [lein-midje "3.1.3"]
                  ]
        :dependencies [
                       [nrepl-inspect "0.4.1"]
                       [compliment "0.2.0"]
                       [ritz/ritz-nrepl-middleware "0.7.0"]
                       [cider/cider-nrepl "0.9.0"]
                       [alembic "0.2.1"]
                       [org.clojure/tools.nrepl "0.2.10"]
                       ]
        :repl-options {:nrepl-middleware
                       [
                        cider.nrepl.middleware.classpath/wrap-classpath
                        cider.nrepl.middleware.complete/wrap-complete
                        cider.nrepl.middleware.info/wrap-info
                        cider.nrepl.middleware.inspect/wrap-inspect
                        cider.nrepl.middleware.stacktrace/wrap-stacktrace
                        cider.nrepl.middleware.trace/wrap-trace
                        ]}
        }}

I have eliminated :repl-options from it, the result was the same.

{:user {:plugins [
                  [lein-try "0.4.3"]                  
                  [lein-ancient "0.6.4" :exclusions [org.clojure/core.cache]]
                  [lein-bikeshed "0.2.0"]
                  [lein-ritz "0.7.0"]
                  [lein-marginalia "0.8.0"]
                  [http-kit/lein-template "1.0.0-SNAPSHOT"]
                  [cider/cider-nrepl "0.9.0"]
                  [cljs-complete "0.1.1"]                  
                  [lein-immutant "2.0.0"]
                  [lein-droid "0.3.0-beta4"] 
                  [lein-hadoop-cluster "0.1.2"]
                  [jonase/eastwood "0.2.1"]
                  [lein-midje "3.1.3"]
                  ]
        :dependencies [
                       [nrepl-inspect "0.4.1"]
                       [compliment "0.2.0"]
                       [ritz/ritz-nrepl-middleware "0.7.0"]
                       [cider/cider-nrepl "0.9.0"]
                       [alembic "0.2.1"]
                       ;;[org.clojure/tools.nrepl "0.2.7"]
                       [org.clojure/tools.nrepl "0.2.10"]
                       ]
        }}

It seems everything is ok except (ns ...) expression and I can continue to use cider by copying and
pasting (ns ...) expression into cider-repl window.

I have tested with cider-20150617.753.

@expez
Copy link
Member

expez commented Jun 18, 2015

Did you call cider-jack-in on this project, or were you connected to a repl started in another project?

@bbatsov
Copy link
Member

bbatsov commented Jun 18, 2015

Btw, you should also remove nrepl-inspect, compliment and ritz from your deps. I'm not sure why you've added alembic, but you can probably remove it as well.

@ogis-hashi
Copy link
Author

I called cider-jack-in on this 'dummy' project.
I tested with the following ~/.lein/projects.clj, but the result was the same.

{:user {:plugins [
                  [lein-try "0.4.3"]
                  ;[lein-ancient "0.6.4" :exclusions [org.clojure/core.cache]]
                  ;[lein-bikeshed "0.2.0"]
                  ;[lein-marginalia "0.8.0"]
                  ;[http-kit/lein-template "1.0.0-SNAPSHOT"]
                  [cider/cider-nrepl "0.9.0"]
                  ;[cljs-complete "0.1.1"]
                  ;[lein-immutant "2.0.0"]
                  ;[jonase/eastwood "0.2.1"]
                  ;[lein-midje "3.1.3"]
                  ]
        :dependencies [
                       ;;[nrepl-inspect "0.4.1"]
                       [cider/cider-nrepl "0.9.0"]
                       ;;[alembic "0.2.1"]
                       [org.clojure/tools.nrepl "0.2.10"]
                       ]
        }}

@bbatsov
Copy link
Member

bbatsov commented Jun 18, 2015

@tokomakoma123 Have a look at the troubleshooting section of the readme. The *nrepl-messages* contents might help us make some progress here.

@ogis-hashi
Copy link
Author

I've set (setq nrepl-log-messages t) in my init.el and obtained info here.
Is this helpful ?

(--->
  op  "clone"
  id  "1"
)
(<-
  id  "1"
  new-session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  session  "a77ef47f-1586-4fad-a4cf-c052465eaa9d"
  status  ("done")
)
(--->
  op  "clone"
  id  "2"
)
(<-
  id  "2"
  new-session  "c9a12c57-3e77-401d-afb4-316d0a291e71"
  session  "f76bf398-014f-4115-8b76-aec8b9fb1536"
  status  ("done")
)
(--->
  op  "describe"
  id  "3"
)
(<-
  aux  (dict
         current-ns  "user"
       )
  id  "3"
  ops  (dict
         apropos  (dict)
         classpath  (dict)
         clone  (dict)
         close  (dict)
         complete  (dict)
         complete-doc  (dict)
         debug-input  (dict)
         describe  (dict)
         eldoc  (dict)
         eval  (dict)
         format-code  (dict)
         format-edn  (dict)
         info  (dict)
         init-debugger  (dict)
         inspect-pop  (dict)
         inspect-push  (dict)
         inspect-refresh  (dict)
         interrupt  (dict)
         load-file  (dict)
         ls-sessions  (dict)
         macroexpand  (dict)
         ns-list  (dict)
         ns-path  (dict)
         ns-vars  (dict)
         pprint-middleware  (dict)
         refresh  (dict)
         refresh-all  (dict)
         resource  (dict)
         resources-list  (dict)
         retest  (dict)
         stacktrace  (dict)
         stdin  (dict)
         test  (dict)
         test-stacktrace  (dict)
         toggle-trace-ns  (dict)
         toggle-trace-var  (dict)
         undef  (dict)
       )
  session  "ed2886ca-0215-4fcd-9fc3-3c4ecf2afe76"
  status  ("done")
  versions  (dict
              clojure  (dict
                         incremental  0
                         major  1
                         minor  6
                         version-string  "1.6.0"
                       )
              java  (dict
                      incremental  "0"
                      major  "1"
                      minor  "8"
                      update  "40"
                      version-string  "1.8.0_40"
                    )
              nrepl  (dict
                       incremental  "10"
                       major  "0"
                       minor  "2"
                       qualifier  ""
                       version-string  "0.2.10"
                     )
            )
)
(--->
  op  "eval"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  code  "(str *ns*)"
  id  "4"
)
(<-
  id  "4"
  ns  "user"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  value  "\"user\""
)
(<-
  id  "4"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  status  ("done")
)
(--->
  op  "eval"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  code  "(when (clojure.core/resolve 'clojure.main/repl-requires)\n      (clojure.core/map clojure.core/require clojure.main/repl-requires))"
  id  "5"
)
(--->
  op  "eval"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  code  "(try\n      (require 'cider.nrepl.version)\n      (:version-string @(resolve 'cider.nrepl.version/version))\n    (catch Throwable _ \"not installed\"))"
  id  "6"
)
(<-
  id  "5"
  ns  "user"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  value  "(nil nil nil)"
)
(<-
  id  "5"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  status  ("done")
)
(<-
  id  "6"
  ns  "user"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  value  "\"0.9.0\""
)
(<-
  id  "6"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  status  ("done")
)
(--->
  ns  "dummy.core"
  op  "eval"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  code  "(ns dummy.core)"
  id  "7"
)
(<-
  id  "7"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  status  ("namespace-not-found" "done" "error")
)
(<-
  id  "7"
  session  "cf24d741-342f-44fc-a1eb-c7ae8ad820fa"
  status  ("done")
)

@bbatsov
Copy link
Member

bbatsov commented Jun 18, 2015

I see the problem. It's trying to evaluate the ns in the ns of the current file instead of user. You can sidestep this by using C-c C-k and we should check what goes wrong.

This is accounted for here https://github.com/clojure-emacs/cider/blob/master/cider-interaction.el#L1588

What command are you using to eval the ns? (my guess is that we're not invoking prep-eval for some interactive evaluation command)

@ogis-hashi
Copy link
Author

The cider-eval-buffer(C-c C-k) works fine.
The cider-eval-ns-form(C-c C-n) and cider-eval-last-sexp(C-c C-e) don't
work.

2015-06-18 17:03 GMT+09:00 Bozhidar Batsov notifications@github.com:

I see the problem. It's trying to evaluate the ns in the ns of the current
file instead of user. You can sidestep this by using C-c C-k and we
should check what goes wrong.

This is accounted for here
https://github.com/clojure-emacs/cider/blob/master/cider-interaction.el#L1588

What command are you using to eval the ns?


Reply to this email directly or view it on GitHub
#1139 (comment)
.

@bbatsov
Copy link
Member

bbatsov commented Jun 19, 2015

OK, got it. I see the problem and I'll fix it soon. It's here https://github.com/clojure-emacs/cider/blob/master/cider-interaction.el#L1592

Basically, the order of those checks kind of sucks. The ns-form check should be higher up.

@bbatsov
Copy link
Member

bbatsov commented Jun 19, 2015

Actually, the problem is different - when the prep eval was introduced the special logic to eval ns forms always in the user namespace got lost somewhere. //cc @cichli

@bbatsov
Copy link
Member

bbatsov commented Jun 19, 2015

Btw, this is also @Malabarba's problem - he said a few times he gets "Namespace not found error" in cases when the ns should have been automatically evaluated. That's a pretty serious oversight on our part. I cannot believe more people haven't noticed it. Guess most users just start by doing C-c C-k which masks the problem.

@ogis-hashi
Copy link
Author

Great ! It worked.
Thanks,
Makoto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants