0
votes

I am using cider and leiningen for Clojure projects. But I am unable to add dependencies, or any library for the matter in a project after creation. But when I create a new project and add the same libraries, I don't see any errors then. Is this a bug or am I doing something wrong?

Walkthrough the problem:

1. lein new projectname
2. adding required libraries in project.clj and then lein deps
3. now write code in src/projectname/core.clj using the added libraries; works fine.

4. I forgot to add one more library; so back to step 2; done. Then step 3; failed!

5. Now make new project lein new projectname2
6. adding all the libraries which I required in projectname in project.clj
7. now write code in src/projectname2/core.clj using the added libraries; works fine.

1
Can you describe a minimal set of steps one could take to reproduce the problem you're having?jas
+1 for more accurate step for reproduction of the problem. could if be, that you start a repl and it keeps running for your session? maybe your editor starts one? so after adding new deps to the project.clj those are just there but visible in the running repl. you would have to restart that repl to get the new deps.cfrick
there are ways to hot-load deps into a running repl, but for a beginnter it might be better to stick to the reload.cfrick
Added a little detailed walking through the problem.sawan

1 Answers

1
votes

In emacs cider for changes to the project.clj to take effect, you need to restart the session.

The most straightforward is to quit and reconnect:

M-x cider-quit
M-x cider-jack-in-clj

Or the equivalent short cuts, which for me would be C-c C-q C-c M-j

You can also do a restart, but note that it has to be a "hard" restart (good info on that here: https://metaredux.com/posts/2019/11/07/hard-cider-hard-restart.html)

M-x sesman-restart

Or (for me, at least) C-c C-s r

Hence:

  1. lein new projectname
  2. adding required libraries in project.clj and then lein deps

    2a. If you're currently in a cider session, restart it

  3. Write code in src/projectname/core.clj using the added libraries; works fine.

  4. Forgot to add one more library; so back to step 2; done.