Fork me on GitHub
#practicalli
<
2021-08-02
>
Mícheál Ó Catháin13:08:42

Forgive me if this is not the place to post troubleshooting questions about the Clojure Web online book and associated video playlist - please set me straight if so! I'm working through the excellent "https://practical.li/blog/posts/clojure-web-server-cli-tools-deps-edn/" and associated https://www.youtube.com/watch?v=SPSn02RxpxM&amp;list=PLpr9V-R8ZxiDjyU7cQYWOEFBDR1t7t0wv&amp;index=52. Whether from rebel readline or jacked in within Cider, I am unable to execute the functions within the simple-api-server.clj from within the namespace itself. Within the rebel readline repl I can require the simple-api-server namespace and start and stop the server that way - so the project and code does seem to be set up correctly. Not only can I not access the namespace functions from within simple-api-server namespace, I can't seem to access many of the most common clojure functions e.g. (+ 1 2 3), throwing the error "Unable to resolve symbol: + in this context". Most strangely this issue does not seem to be consistent - out of about 10 times I've tried to connect a rebel readline repl to the simple-api-server namespace I have gotten this error about 8 times, however twice or so it has worked as expected. Clearly there is something basic amiss within my setup, but I am unable to figure out where to begin troubleshooting - any help would be appreciated!

practicalli-johnny16:08:12

This is the right place to ask questions

practicalli-johnny16:08:21

So in summary, you can evaluate expressions in the Rebel repl command line. However, using Cider jack-in or connect, not even core Clojure functions evaluate.

practicalli-johnny16:08:41

Cider does need either a Clojure buffer or a namespace evaluated as the first thing to do after the repl has started.

practicalli-johnny16:08:00

As the code runs in Rebel, then if the above doesn't work, it seems likely to be an issue with the Cider install.

practicalli-johnny16:08:44

Although this f you did get Cider to work on occasion, it's probably due to evaluation of a Clojure buffer or ns expression. Without evaluating at least a namespace, only the 12 or so special forms work in Cider https://clojure.org/reference/special_forms

practicalli-johnny16:08:37

If this doesn't help, let me know. Also feel free to share any specific error messages

Mícheál Ó Catháin06:08:22

@U05254DQM thank you very much! Basic misunderstanding on my part - I had not evaluated the (ns ..) expression within my namespace so clojure.core functions were not getting loaded. I had assumed all functions were evaluated and available in the CIDER repl UI. Back on solid ground, thanks again!

Mícheál Ó Catháin06:08:52

And by the way the http://practical.li website is a phenomenal resource. I am now using practicalli/clojure-deps-edn to make the most of the community tools you have curated. I have a rough map now of the incredibly comprehensive learning ecosystem you have created and look forward to chipping away at the books and videos as I gradually become more proficient... kudos and huge thanks!

practicalli-johnny11:08:23

It’s a commonly missed step and I did suggest making this more obvious in the cider docs. I will check the Practicalli books and see if I can make this more obvious. I used to be caught out by this when looking for docs of functions. Even with a running REPL you have to load a buffer or namespace for docs to be found via Cider. Only the dozen special forms are present until that first evaluation

practicalli-johnny11:08:30

Thank you. Please let me know if there are suggestions or additional things you would like to see in any of the work. I can’t promise anything, but if I know people need something then I am more motivated to add it

Mícheál Ó Catháin14:08:40

I should add that this issue is not particular to this project. I started a blank project using clj-new, with the app template, and I hit the same issues.