4

In a fresh lein (~2.5) repl, I type:

 (require '[clojure.string :as string])

And I can use string as expected. However, when trying to require core.asnc like so, I get an error msg:

(require '[clojure.core.async :as ca])
FileNotFoundException Could not locate clojure/core/async__init.class or clojure/core/async.clj on classpath.  clojure.lang.RT.load (RT.java:449)

thanks to your answers I managed now to require arbitrary libs in a repl on runtime using pomegranate or alembic. But what about macros? How - for example - do I get the 'go' macro in the repl? There isn't something like (require-macros ... in analogy to the approach one would take when requiring core.async in a project's ns declaration.

Anton Harald
  • 5,772
  • 4
  • 27
  • 61
  • Is it in your project.clj? – jmargolisvt Feb 13 '16 at 17:00
  • Possible duplicate of [Could not locate clojure/core/async\_\_init.class or clojure/core/async.clj on classpath](http://stackoverflow.com/questions/20037682/could-not-locate-clojure-core-async-init-class-or-clojure-core-async-clj-on-cla) – jmargolisvt Feb 13 '16 at 17:01
  • Your edit it really a new question. It would get more attention as a new question and keep the original intent of this question in tact. Questions aren't a place for conversation, follow-ups, and "thank you's". – jmargolisvt Feb 13 '16 at 19:12

1 Answers1

5

core.async is not part of the clojure.core library. You need to add the core.async jar or sources to your classpath. The easiest way to do this is with a dependency via project.clj, but there are also tools like pomegranate and alembic for doing this at runtime, which could be added to your local profiles.clj.

noisesmith
  • 20,076
  • 2
  • 41
  • 49
  • I checked out alembic, put it to the dependencies of my lein project. when trying to use it in the project's repl (as described on their git page), I got his: ClassNotFoundException alembic.still java.net.URLClassLoader.findClass (URLClassLoader.java:381) – Anton Harald Feb 13 '16 at 17:12
  • got it now. had to (require 'alembic.still) first – Anton Harald Feb 13 '16 at 17:21
  • 1
    do note that alembic needs a project.clj in order to add deps, while pomegranate can add deps even if you are running without a project file – noisesmith Feb 13 '16 at 17:32
  • yes, was just figuring this out, got it working now with both. pom works in a "anonymous" repl. Though I'm not impressed by the simplicity of this workflow: (require ['cemerick.pomegranate :as 'pg]) , (pg/add-dependencies :coordinates '[[mylib "0.1.0"]]) , (require 'mylib) Looks like too many words for "just checking out the lib" – Anton Harald Feb 13 '16 at 17:45
  • or just a simple function doing the default stuff you want in a user.clj – noisesmith Feb 13 '16 at 20:01