Clojure: require and Instaparse

I am trying to use instaparse lib for my clojure project. I use leiningen 2.0 and clojure 1.5.1 in my project dependencies. I add instaparse to my project dependencies as follows:

(defproject bachelor "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/clojure-contrib "1.2.0"] [instaparse "1.1.0"]]) 

And this is my source where I am trying to require lib:

 (ns bachelor.data (:require [clojure.string :as str]) (:require [instaparse.core :as insta]) (:use [clojure.contrib.generic.math-functions]) ) 

When I try to compile, I get the following error message:

cd c: /bachelor/src/bachelor.data/1 compiler comment:

Unknown place: error: java.io.FileNotFoundException: could not find instaparse / core__init.class or instaparse / core.clj on classpath:

company.clj: 1: 1: error: java.io.FileNotFoundException: could not find instaparse / core__init.class or instaparse / core.clj on classpath: (company.clj: 1)

Compilation error.

I checked the classpath for my project and I think instaparse needs to be found there.

lein class path

C: \ bachelor \ test; C: \ bachelor \ SRC; C: \ bachelor \ Dev resources; C: \ bachelor \ resources; C: \ bachelor \ target \ classes; C: \ Users \ Maciej.m2 \ repository \ instaparse \ instaparse \ 1.1.0 \ instaparse-1.1.0.jar; C: \ Users \ Mac iej.m2 \ repository \ org \ clojure \ clojure -contrib \ 1.2.0 \ clojure -contrib-1.2.0.jar; C: \ Users \ Maciej.m2 \ repository \ org \ clojure \ clojure \ 1.5.1 \ clojure -1.5.1.jar

Any ideas what I'm doing wrong?

UPDATE

I updated the result for the lein classpath class. I used to insert the old result.

+3
source share
2 answers

I found out what happened. I created a project with leiningen, but developed a source with Clojure -box or Clooj. I also tried to compile my source using these tools, and that was a mistake. When you run such an IDE, it loads its own classpath and therefore cannot find the library that I would like to use. Now I will compile src with

lein compile

and run it in

lein repl

and everything is working fine.

0
source

Here is an example of a working draft:

project.clj:

 (defproject parse "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [instaparse "1.1.0"]]) 

you don't need strings for contrib, and the string is now embedded in clojure.

Css / parsing /core.clj:

 (ns parse.core (:require [instaparse.core :as insta] [clojure.string :as str])) (def as-and-bs (insta/parser "S = AB* AB = AB A = 'a'+ B = 'b'+")) 

REPL:

 #<Namespace parse.core> parse.core> (as-and-bs "aaaaabbbaaaabb") [:S [:AB [:A "a" "a" "a" "a" "a"] [:B "b" "b" "b"]] [:AB [:A "a" "a" "a" "a"] [:B "b" "b"]]] parse.core> (str/join "," ["a" "b" "c"]) "a,b,c" 

My general list of refinements to the Liningen oddities:

  • run lein deps and restart nrepl / emacs
  • lein clean and restart nrepl / emacs
  • delete the local libs directory (lein v1.x)
  • delete my local maven repository and run lein deps
+2
source

Source: https://habr.com/ru/post/1486698/


All Articles