This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-20
Channels
- # announcements (3)
- # beginners (63)
- # calva (1)
- # cider (24)
- # clj-kondo (98)
- # cljdoc (8)
- # cljsrn (19)
- # clojure (106)
- # clojure-conj (2)
- # clojure-europe (5)
- # clojure-italy (5)
- # clojure-nl (8)
- # clojure-spec (8)
- # clojure-uk (13)
- # clojuredesign-podcast (7)
- # clojurescript (54)
- # core-async (1)
- # cursive (3)
- # data-science (1)
- # datomic (19)
- # fulcro (7)
- # hoplon (1)
- # off-topic (3)
- # re-frame (13)
- # reitit (1)
- # shadow-cljs (234)
- # test-check (10)
- # tools-deps (59)
- # unrepl (1)
- # yada (20)
is there any way that you can specify extra deps on the command line without using an alias?
I've developed a template to help my coworkers quick-start on clojurescript but explaining to them how to add an alias for clj-new
to their .clojure/deps.edn
is just one more annoyance for them to figure out. I'd like to be able to do something like
clj -m clj-new.create --middleware "[seancorfield/clj-new]" some.example
why not clj -Sdeps '{:deps,{seancorfield/clj-new,{:mvn/version,"0.5.5"}}}' -m clj-new.create
that's it!
or perhaps read a deps.edn
from stdin that I could have them just paste in via file descriptor?
clj -i -m clj-new.create some.example <(cat << eof
{:aliases :new {:extra-deps {seancorfield/clj-new
{:mvn/version "0.5.5"}}
:main-opts ["-m" "clj-new.create"]}
eof
)
something like that would also work but I haven't been able to figure that one out yet eitherdoes anyone have an example of the -Sdeps
syntax? Is a string?
clj -Sdeps "{:deps {clj-http {:mvn/version \"3.10.0\"}}}"
?
the command I'm hoping for is
clj -Sdeps '{seancorfield/clj-new {:mvn/version {"0.5.5"}}' -m clj-new.create
ahhh ok
it is literally the text of a deps.edn file
outstanding ... exactly what I needed, works exactly as advertised, thank you!
I’m having a problem loading a namespace which requires t.d.a, using version 0.7.535. I’m getting the following error:
Syntax error compiling at (clojure/tools/deps/alpha/reader.clj:98:5).
No such var: io/read-edn
( "clojure/tools/deps/alpha/reader.clj")
=>
#object[java.net.URL
0x2bf95d38
"jar:file:/Users/colin/.gradle/caches/modules-2/files-2.1/org.clojure/tools.deps.alpha/0.7.535/11de58e45ac07ea473f2322f335ef6d162dffde9/tools.deps.alpha-0.7.535.jar!/clojure/tools/deps/alpha/reader.clj"]
( "clojure/tools/deps/alpha/util/io.clj")
=>
#object[java.net.URL
0x2b2beaaa
"jar:file:/Users/colin/.gradle/caches/modules-2/files-2.1/org.clojure/tools.deps.alpha/0.7.535/11de58e45ac07ea473f2322f335ef6d162dffde9/tools.deps.alpha-0.7.535.jar!/clojure/tools/deps/alpha/util/io.clj"]
the namespace could have been created somehow and added to the lib-map, without loading the source file, stopping require from actually loading it
(get (ns-publics ') 'read-edn)
=> nil
(ns-publics ')
=>
{printerrln #',
write-file #',
slurp-edn #'
If I just restart the REPL and then require http://c.t.d.a.u.io directly, then the publics are wrong right off the bat.
you could change the require function to print debugging information(a stacktrace, maybe clojure.lang.Compiler/LOADER, but I guess that is just a dynamic classloader) every time it is called
you could also see what (.getResource (RT/baseLoader) "clojure/tools/deps/alpha/util/io.clj")
returns, maybe check for aot'ed classfiles too
(.getResource (RT/baseLoader) "clojure/tools/deps/alpha/util/io.clj")
=>
#object[java.net.URL
0x37339a
"jar:file:/Users/colin/.gradle/caches/modules-2/files-2.1/org.clojure/tools.deps.alpha/0.7.535/11de58e45ac07ea473f2322f335ef6d162dffde9/tools.deps.alpha-0.7.535.jar!/clojure/tools/deps/alpha/util/io.clj"]
something like
(alter-var-root #'require (fn [orig]
(fn [& args]
(println (.getResource (clojure.lang.RT/baseLoader) "clojure/core.clj"))
(apply orig args))))
with the funky namespace's resource name instead of clojure/core.clj and then requiring the namespace might show something(alter-var-root #'require (fn [orig]
(fn [& args]
(println (.getResource (clojure.lang.RT/baseLoader) "clojure/tools/deps/alpha/util/io.clj"))
(apply orig args))))
=> #object[user$eval1256$fn__1257$fn__1258 0x1a272414 "user$eval1256$fn__1257$fn__1258@1a272414"]
(require '[])
#object[java.net.URL 0x76f46991 jar:file:/Users/colin/.gradle/caches/modules-2/files-2.1/org.clojure/tools.deps.alpha/0.7.535/11de58e45ac07ea473f2322f335ef6d162dffde9/tools.deps.alpha-0.7.535.jar!/clojure/tools/deps/alpha/util/io.clj]
#object[java.net.URL 0x6db91f0c jar:file:/Users/colin/.gradle/caches/modules-2/files-2.1/org.clojure/tools.deps.alpha/0.7.535/11de58e45ac07ea473f2322f335ef6d162dffde9/tools.deps.alpha-0.7.535.jar!/clojure/tools/deps/alpha/util/io.clj]
And if I use:
(alter-var-root #'require (fn [orig]
(fn [& args]
(println (slurp (.getResource (clojure.lang.RT/baseLoader) "clojure/tools/deps/alpha/util/io.clj")))
(apply orig args))))
then the correct file contents are printed out.I think I've seen that behavior when the namespace in question has already been loaded (why that results in two require calls I have no idea)
in a fresh repl before requiring anything maybe try the ns-publics call for the namespace again
-Adeps loads an uberjar
That won’t play nice with the lib jar
Nothing unusual about how this ns is defined or loaded afaik
could you have some aot classfiles somewhere on the classpath, if they have a newer last modified they will be loaded instead of the clojure source
I’m wondering that. I have the debugger set up, and Compiler.load() is never called.
I don’t think that fn was added till 541