Oh really? Interesting. I'd been resolving each dependency independently and comparing to the top level. Your idea is better.
I wonder if you could build a whole lint suite out of the trace, catching other common errors (hello Jackson and jetty).
Hello all, how to listen in all interfaces for this
:aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:accept,clojure.core.server/repl} -Dfile.encoding=UTF-8"]}}
?I tried :address,10.10.20.whatever
and it didn´t work
-> Exception in thread "main" java.lang.NumberFormatException: Invalid number: 10.10.20.82
@fabrao try escaped double quotes around the IP
@borkdude :aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:address,\"10.10.20.82\",:accept,clojure.core.server/repl} -Dfile.encoding=UTF-8"]}}
-> same error
I tried with '
too, not working
that seems weird to me. can you share the full output?
Exception in thread "main" java.lang.NumberFormatException: Invalid number: 10.10.20.82
at clojure.lang.EdnReader.readNumber(EdnReader.java:224)
at clojure.lang.EdnReader.read(EdnReader.java:136)
at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:766)
at clojure.lang.EdnReader$MapReader.invoke(EdnReader.java:680)
at clojure.lang.EdnReader.read(EdnReader.java:145)
at clojure.lang.EdnReader.read(EdnReader.java:111)
at clojure.lang.EdnReader.readString(EdnReader.java:67)
at clojure.edn$read_string.invokeStatic(edn.clj:46)
at clojure.edn$read_string.invokeStatic(edn.clj:37)
at clojure.core.server$parse_props$fn__8907.invoke(server.clj:152)
at clojure.core.protocols$naive_seq_reduce.invokeStatic(protocols.clj:62)
at clojure.core.protocols$interface_or_naive_reduce.invokeStatic(protocols.clj:72)
at clojure.core.protocols$fn__8159.invokeStatic(protocols.clj:169)
at clojure.core.protocols$fn__8159.invoke(protocols.clj:124)
at clojure.core.protocols$fn__8114$G__8109__8123.invoke(protocols.clj:19)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
at clojure.core.protocols$fn__8136.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__8136.invoke(protocols.clj:75)
at clojure.core.protocols$fn__8088$G__8083__8101.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6828)
at clojure.core.server$parse_props.invokeStatic(server.clj:146)
at clojure.core.server$start_servers.invokeStatic(server.clj:157)
at clojure.core.server$start_servers.invoke(server.clj:157)
at clojure.lang.Var.invoke(Var.java:384)
at clojure.lang.RT.doInit(RT.java:493)
at clojure.lang.RT.init(RT.java:467)
at clojure.main.main(main.java:38)
you need to put that second -D in a separate string
{:aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:address,\"10.10.20.82\",:accept,clojure.core.server/repl}" "-Dfile.encoding=UTF-8"]}}}
let me try
I can't repro what you're getting
I get an error binding that address, but that's to be expected
I would expect that error w/o the quotes around the address
@fabrao Are you doing this from a deps.edn file or from a cmd line with -Sdeps
?
deps.edn
linux, macOS, Windows?
From what I've read, it sounds like a fairly standard approach to publishing library artifacts with deps is to create a pom with clj -S:pom
and then use mvn deploy. When you do this model, are there any best practices regarding how to keep things in sync? For example, do you:
1. Regenerate the pom every time you want to cut a release? This seems wrong as you lose all of your version and other info.
2. Generate the pom once and then maintain it? This seems like a good route, but the main downside I see is keeping dependencies in sync.
I am assuming #2 is the best option. Any tips for syncing dependencies?
@markbastian clojure -Spom
does not overwrite anything in your pom.xml
except <dependencies>
And for publishing to Clojars, you really need a lot more in your pom.xml
file than clojure -Spom
provides.
If you create a new project with clj-new
(typically clj -A:new lib myname/myproject
) it will have a suitable pom.xml
file and then for each release you just run clojure -Spom
, update the version and tag in the pom for the upcoming release, commit and push those pom changes, add a release on GitHub and pull, clojure -A:jar
(because clj-new
makes that alias available), and then clojure -A:deploy
(again, from clj-new
's template)
Ah, I hadn't realized what the pom command did. I thought it generated a pom (replacing the existing). I just did an experiment based on your comment and suddenly things make a lot more sense. Very cool! Thanks for the info.
The :jar
alias is for depstar
and it gets the group, artifact, and version from pom.xml
and builds everything you need inside the .jar
incl. manifest, multi-release, etc.
@borkdude It´s Windows
:aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:address,\"10.10.20.82\",:accept,clojure.core.server/repl}" "-Dfile.encoding=UTF-8"]}}
didn´t work
aaah
The :deploy
alias is for deps-deploy
and it expects
CLOJARS_PASSWORD=<your secret>
CLOJARS_USERNAME=<your username>
to be set in your env vars@fabrao windows is a bit different here maybe. can you try ""
instead of \"
?
oh no, that makes the EDN file invalid
hmm
try two \"
's
Per clojure -h
:
-Spom Generate (or update an existing) pom.xml with deps and paths
or just try WSL2 🙂
but I suspect doubling the double quotes works
\"\"10.10.20.82\"\" and ""10.10.20.82"" -> Invalid Number
Or perhaps just read the t.d.a. wiki about Windows? https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows#escaping-quotes
@seancorfield he isn't using -Sdeps
from the command line, this is in an EDN file
I am pretty sure the same recommendations apply...
sorry ->
Error: Could not find or load main class 10.10.20.82
Caused by: java.lang.ClassNotFoundException: 10.10.20.82
@fabrao There's a #clj-on-windows channel that has real Windows users that have probably solved this problem. You're just kind of flailing right now...
And repositories and source dir
ok Sean
(I would probably try \\"
in the string in deps.edn
tho')
with \\"
didn´t work too
I'm firing up a Windows VM. I'll try a few years and report back in #clj-on-windows
@fabrao, this worked for me on Windows:
{:aliases {:dev {:jvm-opts ["-Dclojure.server.repl={:port,5555,:address,\"\"\"127.0.0.1\"\"\",:accept,clojure.core.server/repl}" "-Dfile.encoding=UTF-8"]}}}
so doubling the escaped quotes, just like I suspected 😎and I verified with netstat that the server was indeed running with clojure -A:dev
(sorry, got distracted by a phone call with my mum in England, but I was getting there I hope...)
FWIW, that format with \"\"\"
around the host IP seems to work on Linux and macOS as well. Which surprised me a bit. I was able to start a REPL with that alias on Powershell, CMD (via powershell clj
), and WSL -- as well as on macOS (Terminal) -- and connect to it via telnet
to verify the socket REPL connection.
Is there a way to just install the deps w/ tools-deps? I'm looking for an equivalent to lein deps
(for caching them in a Docker image build).
@cap10morgan you can just do -Spath
and will print the classpath, downloading the deps as a side effect
-Spath
, -Stree
, and -e nil
seem to be the most commonly mentioned ways to have the CLI just download deps, optionally print some information about them, and just exit.
I like -Stree
myself since it's easier to read than -Spath
if I want to verify the actual dependencies being used.
Or just -e nil
if I don't care.
Great. Thanks!
@borkdude It worked !!! Strange things
@fabrao Might be good to add to the wiki.
Technically that is tripling the escaped quotes
oh wait, I didn't even know I did that.
And weird that it seems to work across all platforms... 😐
haha
With the monorepo root CLJ_CONFIG deps.edn
{:aliases {:dev {:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]}}}
And a local deps.edn
{:aliases {:dev {:extra-deps {...}}
I can pull configuration from the monorepo root CLJ_CONFIG
CLJ_CONFIG=../.clojure clojure -A:dev
However, this doesn’t pass down the :jvm-opts
from the CLJ_CONFIG deps.edn. Is this working as intended? Is there a better way to do this? (I could create another alias with this jvm-opt or perhaps use environment variables.)Aliases do not compose.
there’s a line in the guide: > If multiple maps with these keys are activated, `:jvm-opts` concatenate
that confused me
You can either have an alias in the user-level file (via CLJ_CONFIG
) or in the project-level file. What we did is to have something like :dev-defaults
in the user-level (monorepo) file and then :dev
as an empty alias there and overridden in each project -- and then do CLJ_CONFIG=../defaults clojure -A:dev-defaults:dev
Right, that means across all the aliases you specified.
ah gotcha, thanks for the help!
But they have to be different aliases. I answered in the main channel how we handle this at work.
We have about thirty subprojects in our monorepo (and over 100,000 lines of code overall).
Thank you for sharing your deps.edn btw, I should have studied that a bit more closely…
LMK if you have any Qs -- feel free to DM me any time about it.