This works for me locally but I'm assuming things you haven't provided. What's the deps.edn of repo? what's the deps.edn/command line of the REPL? Did you (require 'local.lib)
? (It is necessary to load the namespace before you call source-fn
.)
- My repo deps.edn:
{:paths ["src"]}
My command line: clj -Sdeps '{:deps {local/repo {:local/root "repo"}}}'
Clojure 1.12.1
user=> (require 'local.lib)
nil
user=> (meta #'local.lib/some-function)
{:arglists ([]), :line 3, :column 1, :file "local/lib.clj", :name some-function, :ns #object[clojure.lang.Namespace 0x14f3c6fc "local.lib"]}
user=> (clojure.repl/source-fn 'local.lib/some-function)
"(defn some-function [] \"hi\")"
"RT/baseLoader cannot access local filesystem paths, only classpath JAR resources." is incorrect. The file system resource path you care about here is NOT an absolute path, it is: (.getResourceAsStream (clojure.lang.RT/baseLoader) "local/lib.clj")
(which is subsequently a path found via the classpath roots, which may be either in directories or jars:
user=> (:file (meta #'local.lib/some-function))
"local/lib.clj"