Trying out a new leiningen template. After running the template command,
the dependencies + project.clj built as expected.
lein new template-name project-name
However, lein run to start the web server threw a No such namespace error, even though the project.clj had the :main namespace.name correctly defined, so far as I can tell.
The template was not a project dependency, so it was not immediately obvious to me if the template was broken or some sort of path issue on my end.
I think I fixed my bug deleting the project and rebuilding with the lein -U update flag, but am still curious how to check the template version number.
How can I check the version number of the template that lein new is running?
I looked in lein help new and found how to specify a version but not how to check the one being used.
Leiningen templates are installed in your .m2 directory. So you could just cd ~/.m2/repository/template-name. There you should see directories named by the versions you have installed.
Related
Checkout dependencies can be used to add another work-in-progress project to your Leiningen project during development (for example: you're developing an app and underlying library in parallel).
However, when a checkout dependency itself has a "traditional" dependency (from Clojars), running lein run in the parent project will throw a java.io.FileNotFoundException since it apparently does not retrieve the "traditional" dependencies of its checkout dependencies.
Is there a way to let a Leiningen project recursively download the dependencies of its checkout dependencies?
My opinion of the "proper" way to do this is to have your project depend on the library in your checkouts directory as a traditional dependency in addition to having it in your checkouts directory.
Then every time you change dependencies, run lein install in your library project. This will cause lein to generate the appropriate jar file and install it into your local maven repo. It does not matter if this library project is finished, because you are not actually running it in this state, just using it to fetch dependencies.
Then when it does work you don't have to do anything to "switch to production" other than remove your checkouts directory. The dependency is already in place in the dependent project.
There is a side effect of using checkouts to work on libraries in that the code is loaded twice. Once from the "depended on" version, and then again from the "checkouts version". This is very occationally a problem for me when I'm using protocols and have to remember to re-load the protocol definition.
I am unable to locate the Leiningen profiles.clj file under .lein on my Mac. I am looking to use a previous version of Luminus by adding the following code to the profiles.clj:
:user {:plugins [[luminus/lein-template "1.16.7"]]}
So when i run:
lein new luminus myproject
I use the 1.16.7 template version of luminus.
Thanks
It should be located at ~/.lein/profiles.clj as you're suggesting.
However, if you've not had need for profiles.clj before, then you have to create it yourself, which is probably why you can't find it.
I set up a new machine recently, and I'm pretty sure that I created the file myself.
My current project is split up in multiple sub-projects using lein-sub. The core sub-project depends on other sub-projects. Right now, I'm typically working through the repl and simply re-compiling the current namespace to get an updated result; However, whenever I update a sub-project, and try to re-compile that namespace, I don't get the updated results for those projects. I've tried to delete everything in target/ and re-installing the dependencies, but nothing is working.
How would I be able to reload sub-projects in the quickest way possible?
lein-sub doesn't put your subprojects on the classpath; if they're available at all, I expect that's due to a lein sub install issued at some point?
For the type of simultaneous interactive development you're asking about you can use Leiningen's built-in checkouts feature. Just create a directory called checkouts in the root of your top-level project and in there create symbolic links to the root directories of the dependencies. You still need to add them as :dependencies to project.clj, but the fresh code from the checkouts will be used. You can then run your REPL in the top-level project while simultaneously working on all of them, reloading the individual namespaces from the dependencies just like you would with those from the top-level project.
See the tutorial (link to the version on master) for a detailed description.
I am unsuccessfully trying to run instant-pdf
lein uberjar
cd target
java -jar instant-pdf-0.2.0-standalone.jar
no main manifest attribute, in instant-pdf-0.2.0-standalone.jar
Do I have to manually edit the jar now?
I am using OpenJDK 7.u13-x86_64.
instant-pdf's project.clj lacks a :main setting, and I bet that's why it's not setting a main class in the jar's manifest. However, the project doesn't specify a main method anywhere in the sources either, so you'd have to add one yourself. See the section on Running Code from the Leningen Tutorial for details on using :main.
#Yogothos pointed out that using the Ring plugin for Leiningen will fix this (quoting his comment below):
The project should be built using lein ring uberjar instead of lein uberjar. The Ring plugin is responsible for creating the main.
It seems Leiningen's compile task looks for source packages to start immediately under the /src directory. I use both Java and Clojure in my project, so my /src directory looks like this:
/src/java/myapp
/src/clojure/myapp
Right now Leiningen is looking for /src/myapp and it's failing out during the compile.
Related, I'd like to know how to manually add directories to the classpath for Leiningen's compile and repl tasks. For example, Enlive's deftemplate function will search the classpath for a named template file. Adding /templates to the classpath would be required for my project to build and run properly.
This will be fixed in Leiningen 1.0 which is currently looking good for a release in the next week or so. Hopefully someone writes a javac plugin for Leiningen too; it should be easy to write as Lein bundles ant so you could just reuse ant's javac task.
Have you tried setting the :root value in your project file?
Looking at the source code for the compile command, it will process only Clojure files anyway and will look for these files under (file (:root project) "src") , so you could set :root to point to "src/clojure/" but would still need a symlink so that "src/clojure/src/" exists...