tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2020-09-24T05:38:10.001900Z

This may be a distraction from real tools.deps work, but was wondering if others had come across a series of articles by Russ Cox on Golang and package versioning. This is one of those articles I have looked at recently: https://research.swtch.com/vgo-principles. One thing I found interesting is the number of different package managers that use SAT solvers to find what collection of modules and their versions to use. In case you are curious, Russ argues that maybe this is a bad idea.

alexmiller 2020-09-24T13:05:03.024800Z

Yeah I’ve read these. Some of the Go stuff is similar to the tools.deps resolution

2020-09-24T15:00:39.025Z

I've only read a couple of Russ Cox's articles, but he seems to do a thorough job of writing about pros and cons of various approaches, with examples.

2020-09-25T04:46:24.036800Z

Out of curiosity, did you consider the go module version approach of using the minimum version among all requests for a dependency, rather than the latest, in Clojure CLI tools? It sounded unintuitive at first, but the examples in those articles do seem to make it pretty clear that it is at least one way to achieve better reproducibility in versions of libraries used by an application.

alexmiller 2020-09-25T04:47:54.037Z

bleh

alexmiller 2020-09-25T04:49:12.037200Z

if you are developing for growth, not breakage, that doesn't make sense

2020-09-25T14:49:03.037400Z

Go has apparently strongly recommended backwards compatibility in APIs and behavior since 2013, before Spec-ulation talk, for similar reasons. I think the "largest of the minimum required versions" of this latest Golang vgo tool is fairly reasonably argued for on the basis of reproducible builds, regardless of whether someone releases a new version of a lib tomorrow. Anyway, not trying to change Clojure CLI tools in this regard.

vlaaad 2020-09-24T06:47:41.003Z

I like the new exec stuff. User deps.edn :

{:aliases {:reveal {:extra-deps {vlaaad/reveal {:mvn/version "1.0.130"}}
                    :ns-default vlaaad.reveal}}}
Starting a repl is as simple as clj -X:reveal repl ❤️

❤️ 1
2020-09-24T06:55:13.004Z

yes, i liked that too. was hoping i could stack -X to use multiple tools (like one could with -A), but i get the impression that's not part of the design intent.

vlaaad 2020-09-24T06:56:55.004600Z

I wonder if that can be done using injected basis

2020-09-24T07:03:05.005600Z

haven't thought about that angle yet, may be there's something to that. i did think one might be able to make one thing that's designed to do the stacking for anything else that might follow its conventions.

practicalli-john 2020-09-24T10:37:46.013200Z

@vlaaad I would encourage people creating tools for Clojure CLI to support theuse the -X flag. As well as using key value pairs for clarity you can also set default values, making the comand line even simpler As example, using Sean's clj-new project and the alias below I can create a library project with a default name by just running the command clojure -X:project/new

:project/new
  {:extra-deps {seancorfield/clj-new {:mvn/version "1.1.215"}}
   :exec-fn    clj-new/create
   :exec-args  {:template lib :name practicalli/playground}
   :main-opts  ["-m" "clj-new.create"]}
I can then choose to over-ride value in the :exec-args default values by including key value pairs on the command line clojure -X:project/new :name practicalli/banking-on-clojure

vlaaad 2020-09-24T10:42:22.013300Z

I mean that's exactly what I do :)

practicalli-john 2020-09-24T10:46:06.015100Z

So I could have an alias similar to this, that would let me do clojure -X:inspect/reveal to run a repl and clojure -X:inspect/reveal :command prepl to run prepl instead

:inspect/reveal
  {:extra-deps {vlaaad/reveal {:mvn/version "1.0.130"}}
   :exec-fn    vlaaad.reveal
   :exec-args  {:command repl}}
Does that make sense? To support versions before the pre-release you could also include main-opts
:inspect/reveal
  {:extra-deps {vlaaad/reveal {:mvn/version "1.0.130"}}
   :exec-fn    vlaaad.reveal
   :exec-args  {:command repl}
   :main-opts  ["-m" "vlaaad.reveal" "repl"]}

dominicm 2020-09-24T10:46:41.015600Z

A lot of tools support later command flags overriding earlier ones anyway 🙂

vlaaad 2020-09-24T11:10:27.015800Z

there is no vlaaad.reveal fn

vlaaad 2020-09-24T11:10:55.016Z

you can use :exec-fn vlaaad.reveal/repl

vlaaad 2020-09-24T11:13:28.016200Z

my example earlier used ns-default because there are various types of repls that I might want to start, so I want that to be a command line option — it doesn’t prevent :exec-fn use

vlaaad 2020-09-24T11:18:15.016400Z

I don’t see why there should be a single top-level function that receives :command as argument, exec-fn already solves the problem of calling different functions in the ns. Various repls in vlaaad.reveal ns are independent functions with their own different arguments, smashing them together would be unnecessary complecting

practicalli-john 2020-09-24T11:42:01.016700Z

I was only suggesting an example of a general form of alias, along the lines of the clj-new as that is all I am familar with at the moment. Looking forward to see what develops with reveal.

2020-09-24T12:04:43.017Z

nice pun 😉

😄 1
2020-09-24T12:13:51.022700Z

i have something for starting a socket repl on a specific port. invocation is like:

clj -X:alc.socket-repl :port 9123
there is also a mode where you don't specify a port and it tries to choose one for you:
clj -X:alc.socket-repl
Socket repl port: 38735
Clojure 1.10.1
user=>
here it will print the chosen port number out so it's less digging around you have to do to get this info to your editor or whatever other tooling. it also makes the port info available programmatically -- jcmd <pid> VM.system_properties should have it show up in the way clojure arranges for it w/ clojure.server.repl=... (i have a separate tool that can obtain this info) at the end it just hands things off to clojure.main/main with --repl. i wish i could use this along with other folks' things -- so far -X doesn't look to be composable. what i should say is not necessarily that, but some way to compose things -- it doesn't have to be via -X.

vlaaad 2020-09-24T12:43:34.023100Z

yeah, I’ll think of a more versatile suggested alias to put into reveal docs once -X is no longer pre-release 👍

seancorfield 2020-09-24T15:44:46.026700Z

Composability of "main" functions is problematic though: there's no guarantee a "main" will exit (if it starts a server, for example) and aliases in general are merged to produce the final configuration that is used to start a (single) program.

seancorfield 2020-09-24T15:46:56.028800Z

What has been suggested (several times, here in this channel) is to write your own "runner" function that takes a list of functions to execute and runs them one after the other. Now that programs can get at the basis easily (if they are run via the CLI tools -- not if they are run via a JAR!), you could pass a list of aliases and the "runner" could walk that list and exec each alias...

seancorfield 2020-09-24T15:47:30.029500Z

...you wouldn't get the same semantics of composition but you would get "multiple main" functions run (and you could control the semantics yourself).

seancorfield 2020-09-24T15:48:12.030300Z

(this is exactly why we have a build script that wraps the CLI: you can specific multiple "commands" to build and it runs the CLI for each command, by way of a shorthand)

alexmiller 2020-09-24T22:33:34.031200Z

has anyone tried the clj prerelease 1.10.1.693 on windows?

alexmiller 2020-09-24T22:34:08.031700Z

I've done a fair amount of testing with it, but would be great if someone else had used it

2020-09-24T23:05:25.036200Z

in case others want to try and don't want to look for instructions (https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows): 0) remove previous installation (for me this was deleteing the ClojureTools folder under Documents\WindowsPowerShell\Modules) 1) download: https://download.clojure.org/install/win-install-1.10.1.693.ps1 2) did the "unblock" thing via properties (right-click on file's icon in windows explorer and choose properties) 3) execute the ps script via powershell 4) choose 2 (for under Documents\WindowsPowerShell\Modules) and wait a bit 5) clj -h to verify version 6) freshly clone a clojure project that uses deps.edn 7) start it via clj something close to those steps worked for me.