6

我正在努力学习clojure.spec。在沿着引导构建工具设置 clojure 项目时,我在需要 clojure.spec.alpha 时遇到以下错误。

Compiling ClojureScript...
• js/app.js
No such namespace: clojure.spec.alpha, could not locate clojure/spec/alpha.cljs, clojure/spec/alpha.cljc, or Closure namespace "clojure.spec.alpha" in f
ile src/cljs/flowparser/app.cljs
Elapsed time: 0.141 sec

我的引导配置如下:

(def +version+ "0.0.1-SNAPSHOT")
(def +description+ "Parses graph DSL for VADE")

(set-env!
  :source-paths #{"src/cljs"}
  :resource-paths #{"resources"}
  :dependencies '[
                  [org.clojure/clojure "1.9.0-alpha16"]
                  [org.clojure/clojurescript "1.9.521"]
                  [org.clojure/core.async "0.3.442"]
                  [adzerk/boot-cljs "2.0.0" :scope "test"]
                  [adzerk/boot-cljs-repl "0.3.3" :scope "test"]
                  [adzerk/boot-reload "0.5.1" :scope "test"]
                  [pandeiro/boot-http "0.8.0" :scope "test"]
                  [com.cemerick/piggieback "0.2.1" :scope "test"]
                  [org.clojure/tools.nrepl "0.2.13" :scope "test"]
                  [weasel "0.7.0" :scope "test"]
                  [crisptrutski/boot-cljs-test "0.3.0" :scope "test"]
                  [binaryage/dirac "1.2.7" :scope "test"]
                  [powerlaces/boot-cljs-devtools "0.2.0" :scope "test"]
                  [proto-repl "0.3.1" :scope "test"]
                  [proto-repl-charts "0.3.2" :scope "test"]
                  [boot-codox "0.10.3" :scope "test"]
                  [adzerk/bootlaces "0.1.13"]])

(require
 '[adzerk.boot-cljs      :refer [cljs]]
 '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
 '[adzerk.boot-reload    :refer [reload]]
 '[pandeiro.boot-http    :refer [serve]]
 '[crisptrutski.boot-cljs-test :refer [test-cljs]]
 '[powerlaces.boot-cljs-devtools :refer [cljs-devtools dirac]]
 '[codox.boot :refer [codox]]
 '[adzerk.bootlaces :refer :all])

(bootlaces! +version+ :dont-modify-paths? true)

(task-options!
  pom {:project     'vadelabs/flowparser
       :version     +version+
       :description +description+
       :url         "https://github.com/pntripathi9417/flowparser"
       :scm         {:url "https://github.com/pntripathi9417/flowparser"}
       :license     {"Eclipse Public License"
                     "http://www.eclipse.org/legal/epl-v10.html"}})

(deftask build []
  (comp (speak)
        (cljs)))

(deftask run []
  (comp (serve)
        (watch)
        (cljs-repl)
        (dirac)
        (reload)
        (build)
        (target)))

(deftask production []
  (task-options! cljs {:optimizations :advanced})
  identity)

(deftask development []
  (task-options! cljs {:optimizations :none}
                 reload {:on-jsload 'flowparser.app/init})
  identity)

(deftask dev
  "Simple alias to run application in development mode"
  []
  (comp (development)
        (run)))

(deftask docs []
  "Generates documentation for the library"
  (comp (codox
          :name "vadelabs/flowparser"
          :description +description+
          :version +version+
          :language :clojurescript
          :output-path ".")
        (target :dir #{"docs"})))

我的主要 app.cljs 文件如下:

(ns flowparser.app
  (:require [clojure.spec.alpha :as spec]))

(defn init []
  "Hello World")

因为我刚刚开始clojure提出有关此类问题的任何建议,都会非常有帮助。

谢谢

4

2 回答 2

10

你在一个特别棘手的时刻拿起规范。Clojure 1.9.0-alpha16 只是将命名空间从 更改clojure.specclojure.spec.alpha.

ClojureScript 已对 master 进行了等效更改,但尚未发布新版本。因此,对于 ClojureScript <= 1.9.521,您需要改为clojure.spec用作所需的命名空间。

于 2017-05-07T13:30:36.873 回答
1

也许需要更新版本的 spec.alpha 可以解决您的问题。

尝试将此添加到您的依赖项

 [org.clojure/spec.alpha "0.1.108"]

维护者的解释在这里https://groups.google.com/d/msg/clojure/10dbF7w2IQo/s5kUM4tCAAAJ

于 2017-05-07T12:28:42.447 回答