1

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!

dgan
  • 1,349
  • 1
  • 15
  • 28
  • 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 Mar 22 '17 at 00:39
  • haha I mean two vertically aligned points,sorry :) I would send you a picture of my terminal to prove but dont know how – dgan Mar 22 '17 at 06:44

2 Answers2

1

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.

Chris Murphy
  • 6,411
  • 1
  • 24
  • 42
  • thank you, this work. Don't know why I supposed "if I import X, then I should require X" .. – dgan Mar 18 '17 at 13:36
  • Hum, still having problems actually.. I am still not able to (require [whatever.core]) during a repl session inside my project... – dgan Mar 21 '17 at 19:22
  • AFAIK require always has an :as which is missing in your example. All these different types of importing are a bit frustrating I agree. Personally I don't do much importing at the REPL, although I do use it a fair bit. See also http://stackoverflow.com/questions/9810841/clojure-loading-dependencies-at-the-repl. – Chris Murphy Mar 21 '17 at 21:40
0

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])

Ivan Grishaev
  • 1,583
  • 10
  • 15