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

12,466

Solution 1

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

Solution 2

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

lein -U jar
Share:
12,466
hiroprotagonist
Author by

hiroprotagonist

Updated on June 04, 2022

Comments

  • hiroprotagonist
    hiroprotagonist almost 2 years

    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?

  • hiroprotagonist
    hiroprotagonist about 12 years
    Thank you! This is exactly the information I was looking for.
  • uvtc
    uvtc almost 12 years
    Note that in lein 2, jars are no longer copied to a project lib directory.