dakrone / cheshire

Clojure JSON and JSON SMILE (binary json format) encoding/decoding

Home Page:https://github.com/dakrone/cheshire

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using the Ubuntu Cheshire package with Clojure

jviotti opened this issue · comments

Ubuntu 20.04 provides a libcheshire-clojure package. I understand that you might not be officially supporting this package, but I was hoping you could guide me on how to make use of it.

I'm able to use Cheshire by defining a deps.edn file with the desired version, like this:

{:deps {cheshire/cheshire {:mvn/version "5.10.0"}}}

However, I want to also test the version included with Ubuntu Packages, but I can't get Clojure to find it. This is what I'm doing:

# (1) Install the dependencies
$ sudo apt install clojure libcheshire-clojure

# (2) My sample program
$ cat encode.clj 
(ns smile-encode (:require [cheshire.core :refer :all]))
...

# (3) Run the program
$ clojure encode.clj
...
Syntax error (FileNotFoundException) compiling at (formats/smile/encode.clj:1:1).
Could not locate cheshire/core__init.class, cheshire/core.clj or cheshire/core.cljc on classpath.
...

Is there anything specific I need to do to tell Clojure to find Cheshire as installed using Ubuntu Packages? I'm not very familiar with Clojure, so any pointers would be appreciated!

I'm guessing that the presence of a deps.edn file instructs Clojure to set the class path corresponding to the location of the dependencies file, where as I might need to manually set the class path to point to the system location. However, not sure if this is the problem and what the system location is supposed to be.

Thanks!

I was able to make it work. The trick seems to be passing every JAR you need to the class path. For example:

java -cp /usr/share/java/cheshire.jar:/usr/share/java/clojure.jar clojure.main test.clj