2

I follow the Clojurescript QuickStart on Window 7 and stuck with the final point - run with Leiningen.

Simple command:

lein run -m clojure.main repl.clj

returns error with enormous stacktrace which starts so:

clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could not locate cljs/repl__init.class or cljs/repl.clj on classpath: , compiling:(X:\n\code\hello_world\repl.clj:1:1)

I've search the web and found nearest case, but I've just copied whole code from the site, so I believe there is no typo.

What am I missing?

repl.clj:

(require 'cljs.repl)
(require 'cljs.build.api)
(require 'cljs.repl.browser)
(cljs.build.api/build "src"
  {:main 'hello-world.core
   :output-to "out/main.js"
   :browser-repl true
   :verbose true})
(cljs.repl/repl (cljs.repl.browser/repl-env)
  :watch "src"
  :output-dir "out")

Update:
I've created project 'hw' with lein, copied repl.clj to the project root directory as well as cljs.jar. Also I've copied cljs.jar to src directory (it was mentioned in the quick start guide that src goes to classpath automatically), but result is the same.

project.clj:

 (defproject hw "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"]]
      :main ^:skip-aot hw.core
      :target-path "target/%s"
      :profiles {:uberjar {:aot :all}})

Update 2
Also no luck even with adding clojurescript as dependency:

(defproject hw "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"]
                 [org.clojure/clojurescript "1.7.170"]
                 ]
  :main ^:skip-aot hw.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

Putting cljs.jar to lib directory didn't help either.
https://youtu.be/ciCQ_Nkis4I

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Karen Fisher
  • 747
  • 1
  • 8
  • 25
  • Could you please include your `project.clj`? It looks that ClojureScript jar might not be added by lein to classpath. – Piotrek Bzdyl Oct 23 '17 at 07:20
  • In the Leiningen section it mentions to run `lein classpath`. If you run this you will (I suspect) see that cljs.jar is not there. The usual thing thing to do with Leiningen is just put a reference to ClojureScript in your dependencies, similar to the one you have there for Clojure. – Chris Murphy Oct 24 '17 at 06:32
  • Thank you for advice, but unfortunatelly src dir is in lein classpath https://youtu.be/S7aQAmoqNpM. I'll try with dependencies. – Karen Fisher Oct 25 '17 at 01:24
  • The `src` directory is only for picking up source files. You want to (but currently won't) see the jar file mentioned. What do you get when you put the jar file in the `\lib` directory you need to create? You should get directories and jars from `lein classpath`. For example in my own project this is an example directory: `/home/chris/IdeaProjects/b00ks/src/main:`. This is an example jar file: `/home/chris/.m2/repository/clj-time/clj-time/0.11.0/clj-time-0.11.0.jar:` – Chris Murphy Oct 25 '17 at 03:40
  • After changing your project file do `lein clean` and `lein deps` to make sure the dependencies are picked up. – Chris Murphy Oct 28 '17 at 19:42

1 Answers1

0

For Leiningen to pick up cljs.jar you need to create a lib directory off your project root directory and put cljs.jar in there. The tutorial does mention this under the Dependencies section, which comes just before the Leiningen section:

If you have a few dependencies, one convention is to put them into a folder called lib

I guess you are supposed to infer that Leiningen follows this convention.

My evidence for this working is here: leiningen - how to add dependencies for local jars?

However notice there's a comment at the bottom:

As of Leiningen v2, the lib/ directory functionality has been removed.

So the Quickstart tutorial is out of date.

I would recommend going straight to figwheel for an introduction to Clojurescript, despite what is said there.

Chris Murphy
  • 6,411
  • 1
  • 24
  • 42
  • I didn't test this but relied on the answer here: https://stackoverflow.com/questions/2404426/leiningen-how-to-add-dependencies-for-local-jars. To be honest I would recommend going straight to figwheel for an introduction to Clojurescript: https://github.com/bhauman/lein-figwheel/wiki/Quick-Start (despite what is said there). – Chris Murphy Oct 25 '17 at 06:19