Invalid token error when dependency artifact starts with a number
sanel opened this issue · 1 comments
- Updating to using the latest released version of Leiningen (
lein upgrade
). - Moving your
~/.lein/profiles.clj
(if present) out of the way. This contains third-party dependencies and plugins that can cause problems inside Leiningen. - Updating any old versions of plugins in your
project.clj
, especially if the problem is with a plugin not working. Old versions of plugins like nREPL and CIDER (as well as others) can cause problems with newer versions of Leiningen. - (If you are using Java 9 or newer), updating your dependencies to their most recent versions. Recent JDK's have introduced changes which can break some Clojure libraries.
Describe the bug
When the project dependency artifact starts with a number, leiningen will throw java.lang.RuntimeException: Invalid token
error.
To Reproduce
Steps to reproduce the behavior:
- Create a new project
demo
. - Copy/paste in project.clj the code down below
(defproject demo "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.10.1"]
[com.github.2captcha/2captcha-java "1.0.1"]]
:repl-options {:init-ns demo.core})
After running lein deps
, it will throw exception:
...
Caused by: java.lang.RuntimeException: Invalid token: com.github.2captcha/2captcha-java
at clojure.lang.Util.runtimeException (Util.java:221)
clojure.lang.LispReader.interpretToken (LispReader.java:412)
clojure.lang.LispReader.read (LispReader.java:305)
...
Workaround is to set dependency as a string, e.g.
["com.github.2captcha/2captcha-java" "1.0.1"]
Expected behavior
Leiningen should download 2captcha library.
Environment
- Leiningen Version: 2.9.6
- JDK Version: 1.8.0_292 OpenJDK 64-Bit
- OS: Slackware 14.2 64-Bit
Leiningen uses the Clojure reader to load project.clj
files, and thus it is subject to the limitations of Clojure when it comes to rules about what constitutes a valid symbol. The desired behavior is not really possible without completely rewriting the project-loading code. The best we can do is offer a workaround as documented near the end of the FAQ.