Fork me on GitHub
#practicalli
<
2021-04-27
>
Oliver08:04:32

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?

Oliver08:04:26

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

Oliver12:04:01

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.

Oliver13:04:23

It works after I restarted Spacemacs.

practicalli_john14:04:40

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

Oliver14:04:04

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

practicalli_john14:04:09

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_john14:04:46

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_john14:04:35

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

practicalli_john14:04:19

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

Oliver14:04:45

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

Oliver14:04:39

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.

Oliver14:04:20

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

practicalli_john14:04:57

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_john14:04:15

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_john14:04:47

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

practicalli_john14:04:39

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

Oliver15:04:53

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

practicalli_john15:04:15

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.

Oliver15:04:26

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

practicalli_john15:04:55

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_john15:04:43

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

Oliver15:04:12

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

Oliver15:04:15

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

Oliver15:04:17

...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_john17:04:04

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
Oliver08:05:27

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

practicalli_john17:04:25

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

Aron17:04:19

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