1
votes

This kills me... I cannot require anything other than built-in native deps. No hiccup, no http-kit etc... Even if I can find them on my hard drive in .m2/repository

lein new myapp,

add [markdown-clj 0.9.91] to project.clj,

add (ns metapp.core (:require [markdown-clj :as mark]) )

lein run

Retrieving markdown-clj/markdown-clj/0.9.91/markdown-clj-0.9.91.pom from clojars Retrieving markdown-clj/markdown-clj/0.9.91/markdown-clj-0.9.91.jar from clojars Exception in thread "main" java.io.FileNotFoundException: Could not locate quote/markdown_clj__init.class or quote/markdown_clj.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.,

lein deps is not returning anything

Somebody knows what's wrong please? This stacktrace isn't very helpful, so Lein can fetch deps, but doesn't know how to require them?

EDIT: Running Linux Mint 18.0, clojure is in /home/denis/clojure-1.8.0 and is called by alias java -cp /home/denis/clojure-1.8.0/clojure-1.8.0.jar clojure.main. Directory tree in myapp is /home/denis/prg/cljr/myapp

SOLUTION: Thank you guyz, but now feel like an idiot. So to summarize for future-comers, in project.clj, to ask for a dependency "X" doesn't mean you should "require" it as "X". You must require it the way the author specified in documentation, for example [http-kit "2.2.0"] in project.clj is required as follows

(ns metapp.core (:require [org.httpkit.client :as http] ).

Second, the way you require inside your code is not the same as the way you require in REPL, for example, this works in yourapp.core (require [stuff.core as stuff]). You could also write it like this, it works too (ns yourns (:require [stuff.core :as stuff]). But this synthaxe doesnt work: (:require [stuff.core :as stuff]).

In REPL however, it's different story! I must use (:require '[stuff.core]) if it is an added dependency, or (:require 'clojure.string) if it is a built-in library! Note that something like (require '[http.async.core]) doesn't work because it is not built-in. So if you checked the documentation https://clojuredocs.org/clojure.core/require which only shows built-in examples, like me, you are doomed. Also for built-in library like clojure.string you can use simply (require 'clojure.string), yup, the one which didn't worked with dependencies. Have fun guys! LOOOOONNG journey ahead, clojure is only language so far I needed to spend 4 days figuring out how to IMPORT modules (poke Python, it only took 30 seconds), hope it worth it!

2
I have just tried it once again, and I maintain what I have stated: semicolon is necessary when I require a not-built-in library. Otherwise I have a FileNotFoundException ..not on claspath exception - dgan
haha I mean two vertically aligned points,sorry :) I would send you a picture of my terminal to prove but dont know how - dgan

2 Answers

1
votes

You should require markdown.core. From the documentation for that project:

(ns foo
  (:use markdown.core))

In your case:

(ns metapp.core
  (:require [markdown.core :as mark]))

should work.

Not realising that the name of the library and the namespaces that make up the library are different things is something that is easy to be tripped up by.

0
votes

markdown-clj is just a name of a package. But when you require something, you need to specify a module, not a package. Most of the packages have core module so the proper usage would be:

(:require [markdown-clj.core :as mark])