Search code examples
clojureleiningen

Problems with importing package from Github


before I start, you probably need to know three things:

  1. I don't have Java background
  2. I'm a Clojure newbie - started to learn it
  3. question is related to my "training" package kennyfy

TL;DR version I'm not able to import/use my training package in a project

Longer version
I set myself a goal - write simple API which converts text to kennyspeak. Before that I've created a package (using default lein template).

I tried to import this package to my API.

Part of project.clj looks like this:

:repositories [["jitpack" "https://jitpack.io"]]
:dependencies [[com.github.radmen/clojure-kennyfy "0.1.2"]]

lein deps fetches the package without any problems.

When I try to use it, Clojure fails with following message:

kennyfy-api.core=> (radmen.kennyfy/kenny-speak "foo")

ClassNotFoundException radmen.kennyfy  java.net.URLClassLoader.findClass (URLClassLoader.java:382)

I understand the error, yet I've no idea why this class is not imported.
I am quite sure, that this may be related to the metadata stored in the package, which results in failed imports.

What am I doing wrong?

Thank you

$ java -version
openjdk version "1.8.0_192"
OpenJDK Runtime Environment (build 1.8.0_192-b26)
OpenJDK 64-Bit Server VM (build 25.192-b26, mixed mode)

$ lein version
Leiningen 2.8.3 on Java 1.8.0_192 OpenJDK 64-Bit Server VM

Clojure 1.9.0

Solution

  • A clojure namespaces is loaded the first time it is required.

    foo.core=> (radmen.kennyfy/kenny-speak "foo")
    
    Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
    radmen.kennyfy
    foo.core=> (require '[radmen.kennyfy :as kennyfy])
    nil
    foo.core=> (kennyfy/kenny-speak "foo")
    "mpfppfppf"
    foo.core=> (radmen.kennyfy/kenny-speak "foo")
    "mpfppfppf"
    foo.core=>