practicalli

https://practicalli.github.io/ http://yt.vu/+practicalli (youtube)
Oliver 2021-04-27T08:32:32.041600Z

Hi John, I am trying out your web apps tutorial. I have

(ns hurrlicode.railroad-barons
  (:gen-class)
  (:require [http-kit-server :as app-server]
            [compojure.core :refer [defroutes GET]]))
in src/railroad_barons.clj and
{:paths ["src" "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.10.3"}
        http-kit            {:mvn/version "2.5.3"}
        compojure           {:mvn/version "1.6.2"}}
in deps.edn. But I get this error message:
1. Caused by java.io.FileNotFoundException
   Could not locate http_kit_server__init.class, http_kit_server.clj or
   http_kit_server.cljc on classpath. Please check that namespaces with dashes
   use underscores in the Clojure file name.
Any idea what's going wrong here?

Oliver 2021-04-27T08:37:26.042100Z

Ok, :require [org.httpkit.server :as app-server] seems to work.

Oliver 2021-04-27T12:29:01.044100Z

But now I get a similar error with Hiccup: :thinking_face: deps.edn:

{:paths ["src" "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.10.3"}
        http-kit/http-kit   {:mvn/version "2.5.3"}
        ring/ring-core      {:mvn/version "1.8.1"}
        ring/ring-devel     {:mvn/version "1.8.1"}
        compojure/compojure {:mvn/version "1.6.2"}
        hiccup              {:mvn/version "1.0.5"}}
src/railroad_barons.clj:
(ns hurrlicode.railroad-barons
  (:gen-class)
  (:require [org.httpkit.server :as app-server]
            [compojure.core :refer [defroutes GET POST]]
            [ring.util.response :refer [response]]
            [hiccup.core :refer [html]]
            [hiccup.page :refer [html5 include-js include-css]]
            [hiccup.element :refer [link-to]]))
Error message:
1. Caused by java.io.FileNotFoundException
   Could not locate hiccup/core__init.class, hiccup/core.clj or hiccup/core.cljc
   on classpath.

Oliver 2021-04-27T13:19:23.044700Z

It works after I restarted Spacemacs.

practicalli-john 2021-04-27T14:31:40.045600Z

@oliver.heck Are you restarting the REPL after adding the dependencies to the deps.edn file?

Oliver 2021-04-27T14:32:36.045800Z

👀

Oliver 2021-04-27T14:34:04.047500Z

I guess you say that in every video - but I forgot. :face_with_hand_over_mouth:

practicalli-john 2021-04-27T14:35:09.048700Z

Assuming the requires are spelt correctly and the relevant dependencies are added to the project configuration file (deps.edn), then the error suggests the REPL needs to be restarted. The JVM needs to restart to add a new dependency to the class path, so restarting the REPL (or stop / start the REPL) will add all the namespaces from the dependencies to the class path of the REPL.

practicalli-john 2021-04-27T14:35:46.049400Z

Its easily done, I do it all the time. There is an unofficial way to hotload dependencies into a running REPL so you dont have to restart.

practicalli-john 2021-04-27T14:36:35.050200Z

Although its pretty quick to stop/start a REPL when using Clojure CLI tools, as there is only one JVM.

practicalli-john 2021-04-27T14:37:19.050800Z

Which video / tutorial are you following? It sounds like I need to update the namespaces used.

Oliver 2021-04-27T14:42:45.051600Z

I think they are quite up to date in the banking app but a little outdated in the status monitor.

Oliver 2021-04-27T14:44:39.052700Z

I am able to play around with hiccup now which will keep me busy for a while. Will look into the database topic a little later.

Oliver 2021-04-27T14:47:20.054400Z

Does SPC m s X restart the REPL from within spacemacs?

practicalli-john 2021-04-27T14:51:57.056600Z

I think thats an older binding as I dont have that one anymore. Are you on Spacemacs version 0.200 or version 0.300

practicalli-john 2021-04-27T14:53:15.058100Z

The function to restart properly should be sesman-restart . If you are using cider-restart then that only refreshes the connection and does not reload all the namespaces in the repl. I find the names of some cider functions a little hard to understand... so I wrote this https://practicalli.github.io/spacemacs/clojure-repl/refresh-restart-repl.html#restarting-the-repl

practicalli-john 2021-04-27T14:53:47.058700Z

If in doubt, use cider-quit and cider-jack-in to restart 🙂

practicalli-john 2021-04-27T14:59:39.059700Z

The spacemacs book uses Spacemacs version 0.300 (the develop branch version), so if you have an older version of Spacemacs then some keybindings will be different

Oliver 2021-04-27T15:04:53.060700Z

I think I am on the devel branch - at least it tells me that it's updating very frequently.

Oliver 2021-04-27T15:05:58.060900Z

0.300.0@27.1 (spacemacs)

practicalli-john 2021-04-27T15:14:15.064200Z

Ah yes, thats the develop branch of the Spacemacs configuration. There maybe some commits that have not been pulled for the configuration, but if everything is working then no need to keep up with the very latest.

Oliver 2021-04-27T15:14:26.064400Z

Does spacemacs update the clojure layer automatically? I do not have anything with , m q

practicalli-john 2021-04-27T15:15:55.065600Z

The Spacemacs configuration defines how all the layers work, including the key bindings. This is the approach I recommend when updating. https://practicalli.github.io/spacemacs/install-spacemacs/update.html

practicalli-john 2021-04-27T15:16:43.066500Z

Most of the key binding changes over the last two years have been additive, but there are a few that changed.

practicalli-john 2021-04-27T15:17:54.066900Z

You can see the current key binding configuration for Clojure here https://github.com/syl20bnr/spacemacs/blob/develop/layers/%2Blang/clojure/packages.el#L77

Oliver 2021-04-27T15:19:12.067600Z

I see, I have latest spacemacs version but never ever updated packages. Doing this now.

Oliver 2021-04-27T15:33:15.068600Z

Strangely it says that all packages are up to date now but I still don't have anything under , m

Oliver 2021-04-27T15:38:17.069700Z

...but I found out that I can click on "Clojure" tab in the status bar and get a menu where I can restart sesman. 🙂

practicalli-john 2021-04-27T17:19:04.074400Z

My suggestion is that although you have Spacemacs version 0.300, it is several (many hundreds) of commits behind the current commit on that branch. I added the m sub-menu over a year ago. There will be a large number of commits if you did a pull of the latest Spacemacs, so suggest if you do pull the commits then you have a spare hour to fix anything that breaks (although I havent had any significant issues using develop for the last two years. If you do a pull of the latest develop branch, it is highly advisable to do a diff between your .spacemacs config and the spacemacs.template - use SPC f e D to run a diff in Spacemacs of these two files.

😲 1
Oliver 2021-05-04T08:39:27.088800Z

Finally made the update. Your video was really helpful for that. Thanks! 🎯

practicalli-john 2021-04-27T17:20:25.075Z

Just FYI, In the last two years there have been nearly 5,000 commits to the Spacemacs project.

Aron 2021-04-27T17:37:19.075900Z

nice, i will have to try it again sometime, now that there is a language i can use it for