[英]Unable to add dependencies or libraries in an existing leiningen project
I am using cider and leiningen for Clojure projects.我在 Clojure 项目中使用苹果酒和 leiningen。 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 1. lein new projectname
2. adding required libraries in project.clj and then lein deps 2.在project.clj中添加需要的库,然后lein deps
3. now write code in src/projectname/core.clj using the added libraries; 3. 现在使用添加的库在src/projectname/core.clj中编写代码; works fine.工作正常。
4. I forgot to add one more library; 4. 我忘了再添加一个库; so back to step 2;所以回到第2步; done.完毕。 Then step 3;然后步骤3; failed!失败的!
5. Now make new project lein new projectname2 5. 现在新建项目lein new projectname2
6. adding all the libraries which I required in projectname in project.clj 6.在project.clj的projectname中添加我需要的所有库
7. now write code in src/projectname2/core.clj using the added libraries; 7. 现在使用添加的库在src/projectname2/core.clj中编写代码; works fine.工作正常。
In emacs cider for changes to the project.clj to take effect, you need to restart the session.在emacs苹果酒中对project.clj的改动要生效,需要重启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 Cc Cq Cc Mj
或者等效的捷径,对我来说是Cc Cq Cc Mj
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 )您也可以重新启动,但请注意,它必须是“硬”重新启动(关于此的好信息: https://metaredux.com/posts/2019/11/07/hard-cider-hard-restart。 html )
M-x sesman-restart
Or (for me, at least) Cc Cs r
或者(至少对我来说) Cc Cs r
Hence:因此:
adding required libraries in project.clj and then lein deps在 project.clj 中添加所需的库,然后添加 lein deps
2a. 2a. If you're currently in a cider session, restart it如果您当前在苹果酒 session 中,请重新启动它
Write code in src/projectname/core.clj using the added libraries;使用添加的库在 src/projectname/core.clj 中编写代码; works fine.工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.