Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

0 votes
in Tools by
recategorized by

I have two aliases in my deps.edn:

{
 :deps
 {
  org.clojure/spec.alpha {:mvn/version "0.2.194"}
  aleph/aleph {:mvn/version "0.4.7-alpha7"}
  hiccup/hiccup {:mvn/version "2.0.0-alpha2"}
  }

 :aliases 
 { 
  :web-server {
               :exec-fn web.network-service/run 
               :exec-args {:port 8080} 
               }
  :test-web-server { 
                    :exec-fn test.tnetwork-service/run 
                    :exec-args {:port 9090}
                    }
  }
 }

When invoking

clojure -X:web-server

I get

Function not found: web.network-service/run

Everything is honky dory when invoking

clojure -X:test-web-server

I don't see why would that be, the exec-funs are basically identical. Take a look at full code here: https://github.com/sidesteps/network-grid
I have :paths ["." "src"] in my global deps.edn

2 Answers

+1 vote
by
selected by
 
Best answer

You have a typo in src/web/network_service.clj:

(ns web.netwok-service

There's an r missing so the namespace does not match the filename and cannot be required correctly.

by
thank you kindly for taking a look. That's embarrassing. Perhaps this should have been cough by something in clojure cli pipeline though?
by
If you try it in the REPL (which was how I debugged this), you require web.network-service and it finds a matching file so then it loads it and that leaves you with web.netwok-service as a defined namespace.

A requiring-resolve of web.network-service/run at that point will throw an exception -- and the CLI tells you that the function you requested does not exist.

I guess it could differentiate between nil and an exception at that point and provide a different error message in each case (nil means the ns loaded but the function does not resolve, an exception means the ns failed to load: it's missing or has syntax errors).
by
Nice! Thank you, Alex!
by
lovely, thank you. Will regression test this on my typo when released. The fact that error message displays namespace should put the typo in mistypists' face.
0 votes
by

What version of Clojure CLI (clojure --version)?

Did you try with -Sforce?

by
Clojure CLI version 1.10.3.933

Thanks to Sean Corfield, he spotted a typo in ns declaration in the file of exec-fn. We are thinking perhaps this could have been cought by clojure cli. Please take a look at Seans' suggestion in his comment.
Welcome to Clojure Q&A, where you can ask questions and receive answers from members of the Clojure community.
...