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.
Related
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.
In a project.clj, when you see things like:
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.7.228"]
[com.cemerick/piggieback "0.2.1"]
[org.clojure/tools.nrepl "0.2.10"]
[org.clojure/core.async "0.2.374"]]
and:
:plugins [[org.bodil/lein-noderepl "0.1.11"]
[lein-cljsbuild "1.1.2"]
[lein-npm "0.6.1"]
[lein-repls "1.9.5"]
[lein-doo "0.1.6"]]
Where are these packages coming from? Is it solely Clojars and Maven? Can Lein be configured to get them from GitHub as well?
When these packages are added to your project, is lein merely downloading them and adding them to your java class path? Or something else happening as well?
Where are these packages coming from?
is answered well by What are the leiningen default repositories?
You can use something like lein-git-deps to download dependencies from GitHub, but I would recommend using Maven repos, as this is what the Leiningen ecosystem is built around.
Is lein merely downloading them and adding them to your java class path? Or is something else happening as well?
This deserves some more discussion. When you start a leiningen REPL (for example), Leiningen will first look in its local ~/.m2 repository for all of the dependencies in :dependencies. If it can't find any of them there, it will make a request to each of the repositories for that project to see if they have a copy of that dependency. If they do, Leiningen will download it, then recursively download that dependencies dependencies and so-on. Once all of the dependencies are downloaded, Leiningen will add them all to your application's classpath and start the application.
One thing to keep in mind with Leiningen is that there are two JVM's and two classpaths, one for your application, and one for Leiningen. When you add dependencies to :dependencies they go into your application's classpath, when they are added to :plugins, they go to Leiningen's classpath.
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.
I have got an .so file that needs to be on the class path in order for my program to work. what is the best way of packaging it in a leiningen project?
update
it worked really well... see https://github.com/zcaudate/sigar-native-deps for another example
put them under a directory called native in your lein project as described here.
http://nakkaya.com/2010/04/05/managing-native-dependencies-with-leiningen/
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...