2012-05-24 04:27:17 +00:00
|
|
|
|
# FAQ
|
|
|
|
|
|
2013-02-21 18:18:54 +00:00
|
|
|
|
**Q:** How do you pronounce Leiningen?
|
2012-05-24 04:27:17 +00:00
|
|
|
|
**A:** It's LINE-ing-en. ['laɪnɪŋən]
|
|
|
|
|
|
2013-02-21 18:18:54 +00:00
|
|
|
|
**Q:** What's a group ID? How do snapshots work?
|
2012-05-24 04:27:17 +00:00
|
|
|
|
**A:** See the
|
2013-02-12 01:19:20 +00:00
|
|
|
|
[tutorial](https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md)
|
2012-05-24 04:27:17 +00:00
|
|
|
|
for background.
|
|
|
|
|
|
2013-02-21 18:18:54 +00:00
|
|
|
|
**Q:** How should I pick my version numbers?
|
2012-05-24 04:27:17 +00:00
|
|
|
|
**A:** Use [semantic versioning](http://semver.org).
|
|
|
|
|
|
2013-02-21 18:18:54 +00:00
|
|
|
|
**Q:** What if my project depends on jars that aren't in any repository?
|
2013-05-12 21:11:24 +00:00
|
|
|
|
**A:** You will need to get them in a repository. The
|
2013-02-12 01:19:20 +00:00
|
|
|
|
[deploy guide](https://github.com/technomancy/leiningen/blob/stable/doc/DEPLOY.md)
|
2012-12-14 22:45:30 +00:00
|
|
|
|
explains how to set up a private repository. In general it's easiest
|
2014-05-29 05:03:47 +00:00
|
|
|
|
to deploy them to a static HTTP server or a private S3 bucket. Once
|
|
|
|
|
the repo is set up, `lein deploy private-repo com.mycorp/somejar
|
2013-05-12 21:11:24 +00:00
|
|
|
|
1.0.0 somejar.jar pom.xml` will push the artifacts out. If you don't
|
|
|
|
|
have a pom, you can create a dummy project with `lein new` and
|
|
|
|
|
generate a pom from that. If you are just doing exploratory coding
|
|
|
|
|
you can deploy to `file:///$HOME/.m2/repository` and the jars will
|
|
|
|
|
be available locally.
|
2012-05-24 04:27:17 +00:00
|
|
|
|
|
2014-05-29 05:03:47 +00:00
|
|
|
|
**Q:** I want to hack a project and one of its dependencies, but it's annoying to switch between them.
|
|
|
|
|
**A:** Leiningen provides a feature called *checkout dependencies* to
|
|
|
|
|
make this smoother. See the
|
2013-02-21 18:18:54 +00:00
|
|
|
|
[tutorial](https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md)
|
2012-10-10 18:16:16 +00:00
|
|
|
|
to learn more.
|
2012-05-24 04:27:17 +00:00
|
|
|
|
|
2013-02-21 18:18:54 +00:00
|
|
|
|
**Q:** Is it possible to exclude indirect dependencies?
|
2012-05-24 04:27:17 +00:00
|
|
|
|
**A:** Yes. Some libraries, such as log4j, depend on projects that are
|
|
|
|
|
not included in public repositories and unnecessary for basic
|
2013-02-12 01:19:20 +00:00
|
|
|
|
functionality. Projects listed as `:dependencies` may exclude
|
2012-05-24 04:27:17 +00:00
|
|
|
|
any of their dependencies by using the `:exclusions` key. See
|
|
|
|
|
`lein help sample` for details.
|
|
|
|
|
|
2013-02-21 18:18:54 +00:00
|
|
|
|
**Q:** I specified a dependency on version X but am getting version Y; what's up?
|
2012-05-28 05:00:21 +00:00
|
|
|
|
**A:** One of your dependencies' dependencies has declared a
|
|
|
|
|
dependency on a hard version range, which overrides your "soft"
|
2013-05-30 03:38:50 +00:00
|
|
|
|
declaration. Running `lein deps :tree` will identify which of your
|
|
|
|
|
dependencies are responsible for the version range. You can add an
|
|
|
|
|
`:exclusions` clause to prevent that from affecting the rest of your
|
|
|
|
|
dependencies. See `lein help sample` for how exclusions work. You
|
|
|
|
|
may also want to report a bug with the dependency that uses hard
|
|
|
|
|
version ranges as they cause all kinds of problems and exhibit
|
|
|
|
|
unintuitive behaviour.
|
2012-05-28 05:00:21 +00:00
|
|
|
|
|
2013-11-09 14:40:34 +00:00
|
|
|
|
**Q:** I have two dependencies, X and Y, which depends on Z. How is the version
|
|
|
|
|
of Z decided?
|
|
|
|
|
**A:** The decision depends on which depth and which order the dependencies come
|
2013-11-14 20:06:48 +00:00
|
|
|
|
in the `:dependencies` vector: The dependency at the lowest depth will be
|
|
|
|
|
picked. If there are multiple versions of a single group/artifact at that
|
|
|
|
|
depth, the first of those will be picked. For instance, in the dependency
|
|
|
|
|
graph
|
|
|
|
|
|
|
|
|
|
[Z "1.0.9"]
|
|
|
|
|
[X "1.3.2"]
|
|
|
|
|
[Z "2.0.1"]
|
|
|
|
|
|
|
|
|
|
the direct dependency (`[Z "1.0.9"]`) is picked, as it is closest to the root.
|
2013-11-09 14:40:34 +00:00
|
|
|
|
For the dependency graph
|
2013-11-14 20:06:48 +00:00
|
|
|
|
|
|
|
|
|
[X "1.3.2"]
|
|
|
|
|
[Z "2.0.1"]
|
|
|
|
|
[Y "1.0.5"]
|
|
|
|
|
[Z "2.1.3"]
|
|
|
|
|
|
2013-11-09 14:40:34 +00:00
|
|
|
|
the dependency X comes first, and therefore `[Z "2.0.1"]` is picked. If we
|
|
|
|
|
place Y before X however, `[Z "2.1.3"]` will be picked.
|
|
|
|
|
|
|
|
|
|
Note that this only applies to soft dependencies, and `lein deps :tree` will
|
|
|
|
|
only warn if the latest version is not chosen.
|
|
|
|
|
|
2013-02-21 18:18:54 +00:00
|
|
|
|
**Q:** I'm behind an HTTP proxy; how can I fetch my dependencies?
|
2012-07-27 09:50:33 +00:00
|
|
|
|
**A:** Set the `$http_proxy` environment variable in Leiningen 2.x. You can also
|
2012-07-27 09:54:30 +00:00
|
|
|
|
set `$http_no_proxy` for a list of hosts that should be reached directly, bypassing
|
2012-07-27 09:55:20 +00:00
|
|
|
|
the proxy. This is a list of patterns separated by `|` and may start or end with
|
2012-07-27 09:54:30 +00:00
|
|
|
|
a `*` for wildcard, e.g. `localhost|*.mydomain.com`.
|
2012-05-24 04:27:17 +00:00
|
|
|
|
For Leiningen 1.x versions, see the instructions for
|
|
|
|
|
[configuring a Maven proxy](http://maven.apache.org/guides/mini/guide-proxies.html)
|
|
|
|
|
using `~/.m2/settings.xml`.
|
|
|
|
|
|
2013-02-21 18:18:54 +00:00
|
|
|
|
**Q:** What can be done to speed up launch?
|
|
|
|
|
**A:** The main delay involved in Leiningen comes from starting two
|
|
|
|
|
JVMs: one for your project and one for Leiningen itself. Most people
|
|
|
|
|
use a development cycle that involves keeping a single project REPL
|
|
|
|
|
process running for as long as they're working on that project.
|
|
|
|
|
Depending on your editor you may be able to do this via its Clojure
|
2014-05-29 05:03:47 +00:00
|
|
|
|
integration. (See [nrepl.el](https://github.com/clojure-emacs/cider) or
|
|
|
|
|
[fireplace](https://github.com/tpope/vim-fireplace), for example.)
|
2013-02-21 18:18:54 +00:00
|
|
|
|
Otherwise you can use the basic `lein repl`.
|
2012-05-24 04:27:17 +00:00
|
|
|
|
|
2013-02-21 18:18:54 +00:00
|
|
|
|
**Q:** Still too slow; what else can make startup faster?
|
|
|
|
|
**A:** The wiki has a page covering
|
|
|
|
|
[ways to improve startup time](https://github.com/technomancy/leiningen/wiki/Faster).
|
2013-01-19 01:18:31 +00:00
|
|
|
|
|
2013-07-28 19:51:32 +00:00
|
|
|
|
**Q:** What if I care more about long-term performance than startup time?
|
2013-06-20 07:08:34 +00:00
|
|
|
|
**A:** Leiningen 2.1.0 onward get a speed boost by disabling optimized
|
|
|
|
|
compilation (which only benefits long-running processes). This can
|
|
|
|
|
negatively affect performance in the long run, or lead to inaccurate
|
2014-05-29 05:03:47 +00:00
|
|
|
|
benchmarking results. If want the JVM to fully optimize, you can
|
|
|
|
|
you can switch profiles with `lein with-profiles production run ...`.
|
2013-06-20 07:08:34 +00:00
|
|
|
|
|
2013-03-28 18:00:27 +00:00
|
|
|
|
**Q:** What does "Unrecognized VM option 'TieredStopAtLevel=1'" mean?
|
|
|
|
|
**A:** Old versions of the JVM do not support the directives Leiningen
|
|
|
|
|
uses for tiered compilation which allow the JVM to boot more
|
|
|
|
|
quickly. You can disable this behaviour with `export LEIN_JVM_OPTS=`
|
|
|
|
|
or upgrade your JVM to something more recent. (newer than b25 of Java 6)
|
2013-05-30 03:38:50 +00:00
|
|
|
|
|
2013-06-26 11:53:28 +00:00
|
|
|
|
**Q:** I'm attempting to run a project as a background process (`lein run &`),
|
|
|
|
|
but the process suspends until it is in the foreground. How do I run a program
|
2013-06-26 11:55:05 +00:00
|
|
|
|
in the background?
|
2014-05-29 05:03:47 +00:00
|
|
|
|
**A:** For long-lasting processes, it's better to create an uberjar
|
|
|
|
|
and run that or use `lein trampoline run &`. For short-lived ones,
|
|
|
|
|
both `lein run <&- &` and `bash -c "lein run &"` will work fine.
|
2013-08-20 19:28:28 +00:00
|
|
|
|
|
2014-06-13 22:57:19 +00:00
|
|
|
|
**Q:** I'm getting "could not transfer artifact ... peer not authenticated"
|
|
|
|
|
**A:** This means that either your JVM is not configured with the
|
|
|
|
|
correct certificate authorities, or you're experiencing a
|
|
|
|
|
[man-in-the-middle attack](https://github.com/technomancy/leiningen/issues/1028#issuecomment-32732452)
|
|
|
|
|
on your SSL connection. Leiningen ships with the current Clojars
|
|
|
|
|
public certificate at the time of this writing, so you should be
|
|
|
|
|
able to work around problems with your CA by putting `:certificates
|
|
|
|
|
["clojars.pem"]` in your `:user` profile, assuming the certificate
|
|
|
|
|
that ships with Leiningen hasn't expired.
|
|
|
|
|
|
2014-06-13 23:23:33 +00:00
|
|
|
|
**Q:** How do I determine my project's version at runtime?
|
|
|
|
|
**A:** Leiningen writes a file called `pom.properties` into
|
|
|
|
|
`target/classes` which contains a the version number and current git
|
|
|
|
|
revision of the project. In previous versions of Leiningen this was
|
|
|
|
|
only available when running from jar files, but as of 2.4.1 it's
|
|
|
|
|
available during `lein run ...`, etc. You can read it by running
|
|
|
|
|
this code (replace "group" and "artifact" with values appropriate to
|
|
|
|
|
your project:
|
|
|
|
|
|
|
|
|
|
```clj
|
|
|
|
|
(doto (java.util.Properties.)
|
|
|
|
|
(.load (io/reader (io/resource "META-INF/maven/group/artifact/pom.properties"))))
|
|
|
|
|
```
|
|
|
|
|
|
2013-08-20 19:28:28 +00:00
|
|
|
|
**Q:** I need to do AOT for an uberjar; can I avoid it during development?
|
|
|
|
|
**A:** A reasonable request. Leiningen supports isolating different
|
|
|
|
|
profiles by their target directory. Simply specify `:target-path
|
|
|
|
|
"target/%s"` in order to have each profile set use a different
|
|
|
|
|
directory for generated files. Then you can put your `:aot`
|
2013-11-13 17:06:19 +00:00
|
|
|
|
settings in the `:uberjar` profile, and the .class files created
|
2013-08-20 19:28:28 +00:00
|
|
|
|
from the AOT process will not affect normal development use. You can
|
|
|
|
|
specify the profile-isolated `:target-path` in your `:user` profile if
|
|
|
|
|
you want it applied across all the projects you work on.
|
2014-05-29 05:03:47 +00:00
|
|
|
|
|
|
|
|
|
**Q:** Is there a way to use an uberjar without AOT?
|
|
|
|
|
**A:** As of Leiningen 2.4.0, if you omit `:main` in `project.clj`,
|
|
|
|
|
your uberjars will use `clojure.main` as their entry point. You can
|
|
|
|
|
launch with `java -jar my-app-standalone.jar -m my.entry.namespace
|
|
|
|
|
arg1 arg2 [...]` without any AOT, but it will take longer to launch.
|
2014-08-09 18:41:18 +00:00
|
|
|
|
|
|
|
|
|
**Q:** I'd like to have certain config active only on a certain OS.
|
|
|
|
|
**A:** You can do this by using unquote in the `:dev` profile:
|
|
|
|
|
|
|
|
|
|
```clj
|
|
|
|
|
:profiles {:dev [:dev/all ~(leiningen.core.utils/get-os)]
|
|
|
|
|
:dev/all {...}
|
|
|
|
|
:linux {...}
|
|
|
|
|
:windows {...}
|
|
|
|
|
:macosx {...}}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
You can also check things like `(System/getProperty
|
|
|
|
|
"java.specification.version")` to use the JVM version or any other
|
|
|
|
|
property.
|