How to force lein deps to re-fetch local jars/libs
Asked Answered
S

3

17

using the following instructions:

http://www.pgrs.net/2011/10/30/using-local-jars-with-leiningen/

I installed some local jars into local repository.

When I want to update the jar in my project, I re-install the jar into the repository and then run lein deps. I am finding that somehow, the jar is not updated in my project. Even when I rm -rf everything in the libs folder, the new jar is not picked up. The only way I have been able to get this to work is to change the name of the jar.

Its sort of odd because this occurs even when I have deleted all traces of the old jar (as far as I know) -- does lein hide a snapshot/cache of libs?

Specter answered 8/5, 2012 at 18:10 Comment(0)
R
35

Leiningen uses maven for dependency management. Maven by default stores its repo in

$HOME/.m2/repository

Prior to leiningen version 2, the dependencies would be copied to <projecthome>/lib, but version 2 and later builds a classpath pointing directly to the repository.

So delete the jar in your local maven repo and you should force a (re)download.

Alternatively, it's useful to know that for snapshot dependencies, maven will only check for new versions of the snapshot once a day (by default). In maven you can force it using the -U flag. I don't think leiningen expose that, but you could do.... (but see answer from barry-wark)

# force update of snapshots before starting repl
$ lein -U repl
Refusal answered 8/5, 2012 at 18:44 Comment(2)
Thank you! This is exactly the information I was looking for.Specter
Note that in lein 2, jars are no longer copied to a project lib directory.Teddi
V
13

In lein 2, you can use the -U flag, e.g.:

lein -U jar
Vonnie answered 2/8, 2014 at 0:43 Comment(0)
T
0

delete .m2 folder. And it will refetch.

Tatro answered 1/4, 2019 at 14:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.