Ask coding questions

← Back to all posts
clojure dependencies
sunj (5)

How do I specify dependencies from repl.it?

Commentshotnewtop
PYer (2684)

Also, you should specify what language.

ash15khng (507)

@fullern000 He did, in the title of the post it says "clojure" which is a language supported on [repl.it] apparently. Guess you learn something new everyday.

PYer (2684)

What is a dependency?

[deleted]

Yeah, what is it?

coalesce (1)

@fullern000 The same as in Node and Python - internal and external .clj files which are plugged in to code like this (this file should be in classpath of JVM)

(ns example.core
  (:require [somelib.core :as smlibalias]))
jclavijo (0)

Found a work around.
First you can't name any other file .clj if you want to see the output of the main.clj when you hit run. You can use files with no extensions. So core.clj would be just core and if you put the file in a folder, (ex. "proj/"), also leave no extension in the filename. Using (ns proj.core) will work fine.
Second, use load-file in the main.clj . (load-file "proj/core") before calling
(require 'proj.core) or before using

(ns main
      (:require [proj.core :refer :all]))

That should be enough to call dependencies from files you wrote or created that are not in the version of clojure being used.
Last pro-tip, if you want to build while testing, simply build the file in whatever folder and file structure, load it, require it, and run-test definitions for the ns or from the main.clj

(load-file "proj/core_test")
(require 'clojure.test)
(clojure.test/run-tests 'proj.core_test)
jclavijo (0)

Yea... it seems to be a bug or overlooked component. It might also be that since main is executed and the repl is loaded, any dependencies that are outside of the clojure version running can't be loaded, but it also prevents files created adjacent in the project from being used as dependencies

obiSerra (0)

I had the same problem and I ended up uploading the source code of the library I needed (it was core.match)

ryuhcii (0)

+1 for this.
I needed to use https://github.com/clojure/core.match and couldn't find a way how to add dependencies in repl.it

coalesce (1)

For me it seems that in repl.it only Node and Python is extendable with external libs :(