Displays an error on the line, which is not even. In the project , made on video from Joker 2014 .

Individually, all functions are compiled without error messages. But when you run the run-server from the code, nothing is output to localhost:8080 and an error is generated in the REPL:

 CompilerException java.lang.RuntimeException: No such namespace: ohs, compiling:(NO_SOURCE_PATH:33:3) 

 (ns joker.handler (:require [compojure.core :refer :all] [compojure.handler :as handler] [org.httpkit.server :as ohs] [compojure.route :as route] [ring.middleware.defaults :refer [wrap-defaults site-defaults]])) (defn index [req] {:body (str req) :status 200}) (def stop (ohs/run-server #'app {:port 8080}) ) (comment ;; magic lib (require '[vinyasa.pull :as vp]) (vp/pull 'http-kit) ) (defroutes app-routes (GET "/" [] "Hello World") (route/resources "/") (route/not-found "Not Found")) (def app (handler/site app-routes)) 
  • "when running run-server " how? From REPL? - D-side
  • @Knochkatyk - I run the function from the code, but it turns out it is copied and executed in the REPL - titov_andrei
  • Well, that is, you somehow designate a specific pair of brackets (as I understand it, which is inside the stop ) and send it to the REPL, right? And try to do the same before this with the ns form at the top. - D-side
  • @Knapkatyk - launched all functions in turn and in order, starting with the namespace - titov_andrei
  • No need to act at random. If you had completed the ns form, the ohs namespace would have been. - D-side

1 answer 1

We must understand that this is a live demo , and the code is in an intermediate state . In this way, it is usually not committed, because "as is" it simply will not start.

Riddle in the macro comment . The code inside it is not executed.

 (defmacro comment "Ignores body, yields nil" {:added "1.0"} [& body]) 

And the code is specially wrapped inside it, so that the individual forms from the inside can be executed explicitly, but the execution of the form as a whole (eval file, for example) does not execute them.

Everything that happens is caused by the absence of the http-kit library. And it really is not in your project.clj , so it is missing when you start the REPL. Inside the comment there are forms that pull this library into the current session. The comment form itself is useless, it will not do anything (it unfolds to nil ). It is necessary to fulfill the forms inside it, in order, from top to bottom.

In a good way, you need to add the http-kit to project.clj . And throw comment out of the code altogether, leaving it only in the sandbox for the REPL.

  • "Everything that happens is caused by the absence of the http-kit library" - so there you can see it "on the fly" in the video, and I don’t completely launch the file, but as in the video, each function is in order of the video, and I only got to 16 minutes - so why does the web server start up on video, but I don’t have the same code? - titov_andrei pm
  • @titov_andrei in question, the procedure is not outlined. But the error speaks about it. - D-side
  • I will dig, thanks for the referral - titov_andrei
  • @titov_andrei well, how? Understand what the trouble? - D-side
  • I realized that the materiel is still learning and teaching ... - titov_andrei