Fork me on GitHub
#beginners
<
2018-04-23
>
timo10:04:34

Hi all, I've got a problem that I don't know how to resolve. I am using luminus with cljs/reagent/re-frame and somehow my :require does not work reliably. For example when I am opening doo-runner and run (doo-tests 'dispatcher.core-test) in spacemacs with cider-eval-defun-at-point then it tells me following

----  Compiler Warning on   <cljs form>   line:1  column:2  ----

  Use of undeclared Var dispatcher.doo-runner/doo-tests

  1  (doo-tests 'dispatcher.core-test)
      ^--- 

----  Compiler Warning  ----
#object[TypeError TypeError: Cannot read property 'doo_tests' of undefined]
and when running the tests with lein with-profile test doo phantom once from command line it fails with
2018-04-23 12:33:42,807 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider 

;; ======================================================================
;; Testing with Phantom:

goog.require could not find: dispatcher.semantic_ui

   in onError
Error encountered performing task 'doo' with profile(s): 'dev,test,test'
Subprocess failed
Anyone knows how to debug this? I really don't know how to proceed. Thanks in advance!

timo11:04:16

There is something broken with my setup somehow. When loading a namespace with cider-load-buffer in spacemacs it returns IllegalArgumentException

Show: Project-Only All 
  Hide: Clojure Java REPL Tooling Duplicates  (1 frames hidden)

1. Unhandled java.lang.IllegalArgumentException
   Namespace dispatcher.events does not exist

               closure.clj:  707  cljs.closure/source-for-namespace
               closure.clj:  680  cljs.closure/source-for-namespace
                 repl.cljc:  195  cljs.repl$load_namespace/invokeStatic
                 repl.cljc:  179  cljs.repl$load_namespace/invoke
                 repl.cljc:  220  cljs.repl$load_dependencies/invokeStatic
                 repl.cljc:  216  cljs.repl$load_dependencies/invoke
                 repl.cljc:  540  cljs.repl$load_file/invokeStatic
                 repl.cljc:  519  cljs.repl$load_file/invoke
                 repl.cljc:  670  cljs.repl$fn__17012$self__17014/invoke
                  AFn.java:  165  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj:  652  clojure.core/apply
                 repl.cljc:  654  cljs.repl$wrap_self$g__16987/invoke
                 repl.cljc:  860  cljs.repl$repl_STAR_$read_eval_print__17089/invoke
                 repl.cljc:  903  cljs.repl$repl_STAR_$fn__17095$fn__17104/invoke
                 repl.cljc:  902  cljs.repl$repl_STAR_$fn__17095/invoke
             compiler.cljc: 1205  cljs.compiler$with_core_cljs/invokeStatic
             compiler.cljc: 1194  cljs.compiler$with_core_cljs/invoke
                 repl.cljc:  864  cljs.repl$repl_STAR_/invokeStatic
                 repl.cljc:  737  cljs.repl$repl_STAR_/invoke
            piggieback.clj:  169  cemerick.piggieback/run-cljs-repl
            piggieback.clj:  155  cemerick.piggieback/run-cljs-repl
                  AFn.java:  171  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  661  clojure.core/apply
                  core.clj:  652  clojure.core/apply
            piggieback.clj:  259  cemerick.piggieback/evaluate
            piggieback.clj:  255  cemerick.piggieback/evaluate
            piggieback.clj:  285  cemerick.piggieback/load-file
            piggieback.clj:  284  cemerick.piggieback/load-file
                  Var.java:  381  clojure.lang.Var/invoke
            piggieback.clj:  291  cemerick.piggieback/wrap-cljs-repl/fn/fn/fn
            piggieback.clj:  247  cemerick.piggieback/enqueue/fn
    interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1149  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  624  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  748  java.lang.Thread/run

timo11:04:48

but dispatcher.events is definitely there

dpsutton11:04:48

@timo what does , s b do? Is it loading and setting the namespace?

dpsutton11:04:45

Also what does e f do from your first example

dpsutton11:04:24

It didn't highlight your name @timok

timo11:04:02

@dpsutton Sorry, , e f runs cider-eval-defun-at-point and , s b is cider-load-buffer

dpsutton11:04:55

When you ran eval defun at point had you set the name space?

dpsutton11:04:41

You mentioned the require wasn't working. Just making sure you were in the name space after it was loaded

timo11:04:33

let's see...

timo11:04:24

@dpsutton I tried to require like this in repl

(require 'dispatcher.doo-runner)
----  Could not Analyze  <cljs form>   line:1  column:1  ----

  No such namespace: dispatcher.doo-runner, could not locate dispatcher/doo_runner.cljs, dispatcher/doo_runner.cljc, or Closure namespace "dispatcher.doo-runner" at line 1 <cljs repl>

  1  (require 'dispatcher.doo-runner)
     ^--- 

----  Analysis Error  ----
nil

timo11:04:57

the same as mentioned with cider-load-buffer

dpsutton11:04:32

What's the name of the file that contains the doo-runner ns

timo11:04:58

doo_runner.cljs

dpsutton11:04:23

Can you go to that file and load it in the repl?

timo11:04:07

@dpsutton I used (load-file "test/cljs/dispatcher/doo_runner.cljs") and it failed with

Show: Project-Only All 
  Hide: Clojure Java REPL Tooling Duplicates  (2 frames hidden)

2. Unhandled clojure.lang.ExceptionInfo
   failed compiling file:test/cljs/dispatcher/doo_runner.cljs

1. Caused by clojure.lang.ExceptionInfo
   No such namespace: dispatcher.events-test, could not locate
   dispatcher/events_test.cljs, dispatcher/events_test.cljc, or Closure
   namespace "dispatcher.events-test" in file
   test/cljs/dispatcher/doo_runner.cljs
   {:tag :cljs/analysis-error}
(leaving out the stacktraces)

timo11:04:41

(ns dispatcher.doo-runner
  (:require [doo.runner :refer-macros [doo-tests]]
            [dispatcher.events-test]
            [dispatcher.core-test]
            [dispatcher.time-test]))

(doo-tests 'dispatcher.core-test 'dispatcher.events-test)

dpsutton11:04:01

Ok. What are the source paths for your class path? Are you sure you have the test dir on your class path? A lot of times these are only in a specific profile

timo11:04:38

it worked until a few weeks ago. @dpsutton can you help me with that? How can I get or set the classpath? in Leiningen?

dpsutton11:04:36

Yes. There should be an entry in there like src-paths

dpsutton11:04:12

Just search for test and you'll probably find it. You can see if it's on another profile

dpsutton11:04:46

In project.clj that is

timo12:04:12

:test          [:project/dev :project/test :profiles/test]
   :project/test {:jvm-opts ["-server" "-Dconf=test-config.edn"]
                  :resource-paths ["env/test/resources"]
                  :cljsbuild
                  {:builds
                   {:test
                    {:source-paths ["src/cljc" "src/cljs" "test/cljs"]
                     :compiler
                     {:output-to "target/test.js"
                      :main "dispatcher.doo-runner"
                      :optimizations :whitespace
                      :pretty-print true}}}}}
   :profiles/dev {}
   :profiles/test {}
@dpsutton I thought this looks ok.

timo12:04:37

is :source-paths recursive?

timo12:04:40

maybe this is of relevance for my case? https://dev.clojure.org/jira/browse/CLJS-1473 ( no it's not, I think)

dpsutton12:04:37

so the "test/cljs" source path is there. i'm not sure what :project/test is here to be honest

timo13:04:32

@dpsutton thanks anyways!