Hi guys, I am trying to use cljfmt
.
When I execute
clojure -Sdeps '{:deps {cljfmt/cljfmt {:mvn/version "0.6.4"}}}' -M cljfmt.main fix
I get following error
Exception in thread "main" java.io.FileNotFoundException: cljfmt.main (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:211)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:153)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:108)
at clojure.lang.Compiler.loadFile(Compiler.java:7449)
at clojure.main$load_script.invokeStatic(main.clj:278)
at clojure.main$script_opt.invokeStatic(main.clj:338)
at clojure.main$script_opt.invoke(main.clj:333)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)
make: [format] Error 1 (ignored)
@suren You are missing -m
The README for cljfmt
says:
clojure -Sdeps '{:deps {cljfmt {:mvn/version "0.6.4"}}}' \
-m cljfmt.main check \
--indents indentation.clj
which is “old” and you’ll get a warning about using -M
but the warning means in addition or instead of -A so you need:
clojure -Sdeps '{:deps {cljfmt {:mvn/version "0.6.4"}}}' \
-M -m cljfmt.main check \
--indents indentation.clj
Turns out check
works but fix
does not work.
I got following error
clojure -Sdeps '{:deps {cljfmt {:mvn/version "0.6.4"}}}' \
-m cljfmt.main fix
WARNING: When invoking clojure.main, use -M
No such file: project.clj
-M
is an option for the clojure
script that says “run clojure.main
“, -m
is an option for clojure.main
that says “run this namespace’s -main
function”
That error sounds like cljfmt
only works with Leiningen projects? Weird since it gives the CLI example — albeit for check
.
Yep weird.
I have logged an issue in the repo.
Hmm, it shouldn’t be looking for project.clj
if it doesn’t exist, according to the code.
Do you happen to know any way to install deps.edn
based package locally so that I can import it in another project using lein?
Lein based project can be install locally installed through lein pom; lein jar; lein install
I was hoping we have something similar for deps.edn
@suren 0.6.4 is an old version. I tried 0.7.0 and it works without that error.
@suren You are using depstar
to build the JAR?
Yep I can confirm it works. Thanks.
Checking it out. Thanks @seancorfield
I added a comment to your issue. James will update the README I expect.
depstar
’s readme talks about deps-deploy
which has both :remote
and :local
options for :installer
.
If you had created your project initially using clj-new
, the generated deps.edn
would already have all these tools in place.
(! 1435)-> clojure -X:new :template lib :name suren/example
Generating a project called example based on the 'lib' template.
The lib template is intended for library projects, not applications.
(! 1436)-> cat example/deps.edn
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}}
:aliases
{:test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}}}
:runner
{:extra-deps {com.cognitect/test-runner
{:git/url "<https://github.com/cognitect-labs/test-runner>"
:sha "b6b3193fcc42659d7e46ecd1884a228993441182"}}
:main-opts ["-m" "cognitect.test-runner"
"-d" "test"]}
:jar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.0.211"}}
:exec-fn hf.depstar/jar
:exec-args {:jar "example.jar" :sync-pom true}}
:install {:replace-deps {slipset/deps-deploy {:mvn/version "0.1.5"}}
:exec-fn deps-deploy.deps-deploy/deploy
:exec-args {:installer :local :artifact "example.jar"}}
:deploy {:replace-deps {slipset/deps-deploy {:mvn/version "0.1.5"}}
:exec-fn deps-deploy.deps-deploy/deploy
:exec-args {:installer :remote :artifact "example.jar"}}}}
It also has a fully-populated pom.xml
file which I think you will need for deploying locally anyway.
can I have one git repo that deploys multiple maven artifacts by using separate pom.xml files?
I have submitted the PR.
git repos are just a tree of directories containing files, with no restrictions on the directory structure. You could easily have multiple "projects" inside of that git repo with pom.xml files in as many or few (or none) of those directories as you wish.
@danvingo At work we have a "monorepo" that produces 14 different artifacts, from just over 40 subprojects.
ah I see - yea subdirectories would work - I currently have one directly of code - so to produce multiple artifacts I'd have to have multiple subdirectories, each with it's own pom.xml file?
I’ve posted about our monorepo setup a couple of times recently at https://corfield.org/ and the Polylith book talks about this too but, yes, the core concept is having a subproject for each artifact you want to produce so you can control the “environment” needed for those artifacts, separate from each other.
You might also be interested in Polylith as a way to organize a repo that produces multiple artifacts: https://polylith.gitbook.io/
Suppose I am in namespace a, I would like to know the aboslute path of that name space, e.g., /share/local/clojure/a.clj, how to know that?
Hi. Looking through the code, I cannot find the definition of in-ns, https://github.com/clojure/clojure/blob/7529bc90a35eba940581311d7dfed21fec22b4f5/src/clj/clojure/core.clj#L3413 . Is that something inject by the java land, https://github.com/clojure/clojure/blob/b1b88dd25373a86e41310a525a21b497799dbbf2/src/jvm/clojure/lang/RT.java#L482 ?
It worked thanks @seancorfield
(zipmap [:a :b :c :d :e] (range)) => {:a 0, :b 1, :c 2, :d 3, :e 4} (zipmap (range) [:a :b :c :d :e]) => {0 :a, 1 :b, 2 :c, 3 :d, 4 :e} (zipmap [:a :b :c :d :e] (repeat 1)) => {:a 1, :b 1, :c 1, :d 1, :e 1} (zipmap (repeat 1) [:a :b :c :d :e]) => {1 :e}
Is that normal behavior for the last zipmap?
Just curious.
I just realize this is a silly question. Nevermind. I already get it.
A namespace a.b
corresponds to one of a/b.clj
, a/b.cljc
, or a/b.cljs
relative to a directory on the classpath -- so you'd have to search for a matching file the same what Clojure does.
If you have a Var, you can do (:file (meta #'some-var))
and you will at least get the relative filename (so you won't have to do the .clj
/`.cljc`/`.cljs` dance, but you'll still have search the classpath).
Haha took me a while to realize too. It's because of duplicated keys (i.e. 1)
Yup. That’s only that far.
Pressing ctrl-d won’t quit the rebel repl. Not sure if its’ something related to agent not being shutdown or whatever. How to debug this?
Thanks. For thread-dump, how to perform that?
Dunno, I'd have to look it up myself.
But it has nothing to do with Clojure - it's just a JVM thread dump.
The phenomenon is after pressing Ctrl-D, after some minutes, the process will eventually quit.
That doesn't really add any useful information. Just do a thread dump after hitting Ctrl+d and see what it has.
If calling (shutdown-agents)
before that solves the problem, then it's probably that. :)
If you want to find what thread exactly does that, probably dumping threads can help.
doesn’t solve though.
When you press Ctrl+d, what exactly does it do?
If nothing happens and it keeps responding to input, then it just doesn't handle or doesn't receive Ctrl+d.
If it stops responding, then there are probably other threads that prevent the shutdown that have nothing to do with Clojure agents. A thread dump would still help.
Also, I just tried running rebel without anything else. On my end Ctrl+d worked just fine. If you're trying it within some project or if you have something rebel-related in your ~/.clojure/deps.edn
, maybe it affects rebel so that it behaves the way you see.
https://github.com/cognitect-labs/test-runner/blob/master/src/cognitect/test_runner/api.clj#L14 @alexmiller clojure.pprint is not required first.
How can I run test-runner in a repl?
Currently, it directly terminates the system after finishing: https://github.com/cognitect-labs/test-runner/blob/6323e6b09e086e1b98682c4bcf6ef9702254b285/src/cognitect/test_runner/api.clj#L30
The way I do this in babashka is if there is an ex-info with an :exit
value, I exit the process with that exit code, if nobody else caught the exception. This still allows you to use those functions in the REPL without losing the REPL.
I guess you can just use the cognitect.test-runner
ns from the REPL or use clojure.test
directly
Yes. I am now directly using this function: test
https://github.com/cognitect-labs/test-runner/blob/master/src/cognitect/test_runner.clj#L80
I find the user.clj namespace a little bit weird. If I do a
(:refer-clojure :exclude [test])
in (ns user). The test symbol still got included.Sorry, that was debugging left in accidentally, will remove
user is loaded by Clojure very early in the runtime. I’m not sure if you even have the opportunity to do refer-clojure that way there
removed, released 0.2.1 version, see readme for sha etc