technomancy / leiningen

Moved to Codeberg; this is a convenience mirror
https://codeberg.org/leiningen/leiningen
Other
7.29k stars 1.61k forks source link

Invalid token error when dependency artifact starts with a number #2776

Closed sanel closed 2 years ago

sanel commented 2 years ago

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:

  1. Create a new project demo.
  2. 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

technomancy commented 2 years ago

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.