Fork me on GitHub
#tools-deps
<
2020-10-26
>
onetom08:10:01

i have an alias defined in my deps.edn as follows:

:ion-dev
  {:extra-deps {com.datomic/ion-dev {:mvn/version "0.9.276"}}
   :main-opts  ["-m" "datomic.ion.dev"]}}
if i run /nix/store/6n60jkgpxb1a95wjx3ikhn9nvp5w33yh-clojure-1.10.1.727/bin/clojure -A:ion-dev -Sdeps '{:deps {nrepl {:mvn/version "0.8.0"}...' -m nrepl.cmdline ... it complains
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
WARNING: When invoking clojure.main, use -M
does this mean 1. i have to move the :main-opts into a different alias? 2. the command line should have a -M (without any aliases as a parameter) if i just want to run clojure.main?

onetom08:10:18

im wondering what should be the naming convention for aliases in cases when one want to use some extra dependency both as just a library and as a command-line tool... -A:ion-dev -M:ion-dev/run maybe?

onetom08:10:29

am i supposed to combine aliases which doesn't contain :main-opts with aliases which does? like -M:ion-dev:ion-dev/run? when my deps.edn has:

:ion-dev
  {:extra-deps {com.datomic/ion-dev {:mvn/version "0.9.276"}}}

  :ion-dev/run
  {:main-opts  ["-m" "datomic.ion.dev"]}}

dominicm08:10:58

@onetom needs a -M before the -m, so clojure -A:ion-dev -Sdeps … -M -m nrepl.cmdline …

👍 3
practicalli-johnny10:10:06

@onetom it is not required to have separate aliases, you can use the original :ion-dev alias and just use -M instead of -A . However, the -M (and -A flags) should come after the -Sdeps option and before the -m option (the -A flag does still work out of position though)

clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.0"}...' -M:ion-dev -m nrepl.cmdline 
It is also possible to chain the aliases under -M , especially if there is an alias for nrepl too (this example taken from https://github.com/practicalli/clojure-deps-edn/)
:middleware/nrepl 
  {:extra-deps {nrepl/nrepl {:mvn/version "0.8.2"}}
   :main-opts  ["-m" "nrepl.cmdline"]}
And then simplify the command
clojure -M:ion-dev:middleware/nrepl

onetom12:10:13

sure, but i need the :extra-path in :ion-dev on its own too, without the :main-opts and so far i haven't found any option combination which wouldn't print some kind of warnings.

onetom12:10:35

i went thru the new deps and cli docs and found this section: https://clojure.org/reference/deps_and_cli#_replace_project_environment_tool but it's unclear to me what does `tool` process refer to.

practicalli-johnny12:10:46

:replace-deps will just use the deps specified in the alias, dropping any libraries from the main :deps section. This is useful if you just want to run an external tool, e.g. such as clj-new that creates a new Clojure project. Using the -M option only calls the main namespace from the last alias in a chain, so with -M:ion-dev:middleware/nrepl only the main namespace from :middleware/nrep is called and the :ion-dev is simply adding the library as an additional dependency. I didnt see any other main namespaces on the example shared. I am not clear on why an :icon-dev with only extra paths is required in the scenario shared so far.

onetom13:10:12

to start a development repl (with cursive or cider)

onetom13:10:24

but i want to retain the option of running datomic.ion.dev/-main, since that's the official way to deploy datomic cloud projects.

onetom13:10:56

when i have a repl running already (started with repl related :main-opts), im just using datomic.ion.dev/{push,deploy,deploy-status} directly

Alex Miller (Clojure team)13:10:33

There is no option to use the extra-deps but not the main-opts from an alias

Alex Miller (Clojure team)13:10:53

You should separate those into two separate aliases if you need that

👍 3
arohner14:10:55

Something in my deps is using a version range or SNAPSHOT because every time I run clj, it runs

Downloading: com/amazonaws/aws-java-sdk-cloudwatch/maven-metadata.xml
. Is there a clj command that will help me find which dep that is?

arohner14:10:41

it’s not -Strace or -Stree, because those only tell me the resolved version

Alex Miller (Clojure team)14:10:12

if you do tree, it's probably whatever is above that dep in the tree ?

Alex Miller (Clojure team)14:10:32

I don't think I have any other magic command to tell you more unfortunately

arohner14:10:47

that helps some, thanks

arohner14:10:37

I was able to find the dep depending on cloudwatch (amazonica), but something else is causing

Downloading: org/clojure/clojure/maven-metadata.xml
. I guess I can wipe out ~/.m2/repository and do some grepping

Alex Miller (Clojure team)14:10:18

alternately, use -Sdeps '{:mvn/local-repo "tmp"}'

Alex Miller (Clojure team)14:10:30

build up a new tmp repository instead

👍 3
arohner15:10:44

found it. de.kotka/lazymap specifies:

<dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure</artifactId>
      <version>[1.2,1.6)</version>
      <scope>compile</scope>
    </dependency>

arohner15:10:04

should that always trigger a snapshot check?

Alex Miller (Clojure team)16:10:15

all version ranges will trigger a resolution to the "newest" stable version

arohner16:10:07

even when bounded like that?

Alex Miller (Clojure team)16:10:01

you could :exclude org.clojure/clojure down that path

👍 3
Alex Miller (Clojure team)16:10:27

although based on where the canonicalization happens, that may not help

arohner16:10:10

On https://clojure.org/reference/deps_and_cli, I don’t see any definition for the contents of the :exclusion key

Alex Miller (Clojure team)16:10:26

that may be underdocumented :)

Alex Miller (Clojure team)16:10:35

:exclusions [org.clojure/clojure]

Alex Miller (Clojure team)16:10:52

it looks like lazymap 3.1.1 dropped the version range

Alex Miller (Clojure team)16:10:32

I don't think exclusions will help you here

Alex Miller (Clojure team)16:10:12

at the point where expansion goes to resolve the deps, it's resolving all of them, the exclusions and stuff are handled at a higher level

arohner16:10:27

Putting lazymap 3.1.1 as an explicit dependency fixed it for me

arohner16:10:55

lazymap isn’t a dep of my project, it’s a dep of a dep. Putting lazymap in :override-deps doesn’t seem to do anything. Is it supposed to?

seancorfield16:10:28

@arohner :override-deps only works inside an alias