Fork me on GitHub
#tools-deps
<
2020-09-24
>
andy.fingerhut05:09:10

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.

Alex Miller (Clojure team)13:09:03

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

andy.fingerhut15:09:39

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.

andy.fingerhut04:09:24

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.

Alex Miller (Clojure team)04:09:12

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

andy.fingerhut14:09:03

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.

vlaaad06:09:41

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 ❤️

❤️ 3
sogaiu06:09:13

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.

vlaaad06:09:55

I wonder if that can be done using injected basis

sogaiu07:09:05

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-johnny10:09:46

@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

vlaaad10:09:22

I mean that's exactly what I do :)

practicalli-johnny10:09:06

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"]}

vlaaad11:09:27

there is no vlaaad.reveal fn

vlaaad11:09:55

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

vlaaad11:09:28

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

vlaaad11:09:15

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-johnny11:09:01

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.

sogaiu12:09:43

nice pun 😉

😄 3
vlaaad12:09:34

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

dominicm10:09:41

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

sogaiu12:09:51

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.

seancorfield15:09:46

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.

seancorfield15:09:56

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...

seancorfield15:09:30

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

seancorfield15:09:12

(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)

Alex Miller (Clojure team)22:09:34

has anyone tried the clj prerelease 1.10.1.693 on windows?

Alex Miller (Clojure team)22:09:08

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

sogaiu23:09:25

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.