Fork me on GitHub
#tools-deps
<
2023-01-09
>
Jakub Holý (HolyJak)11:01:14

Hi again! How do I troubleshoot what config clj sees and why it cannot find a library? I have in my :config-user file (`"/home/runner/.config/clojure/deps.edn"`) the following (according to cat):

{:mvn/repos {"cognitect-dev-tools" {:url ""}}}
but when I run
clojure -Sverbose -Sdeps '{:deps {com.datomic/dev-local {:mvn/version "1.0.243"}}}' -e '(println "it works!")'
it fails with > Error building classpath. Could not find artifact com.datomic:dev-local:jar:1.0.243 in central (https://repo1.maven.org/maven2/) so it seems to ignore this config?! I have no idea where to look for what is wrong 😭 🙏

Alex Miller (Clojure team)15:01:23

You can use -Sverbose to print your path info to see where it’s looking

Alex Miller (Clojure team)15:01:55

But I think here you’re just seeing a confusing error as all repos are checked but it only reports the last failure

Alex Miller (Clojure team)15:01:01

I would ask in #datomic and they can help diagnose there

Jakub Holý (HolyJak)15:01:26

Thank you! I used Sverbose, that's how I fixed my first error and corrected the user deps location. But obviously Clj still does not see all I expect it to see. Locally if I try to remove settings.xml then I get som 4xx error, which I do not see here. So what else could be wrong? Good to know at least that Clj might be trying the correct repo.

Jakub Holý (HolyJak)16:01:37

Update: instead of relying on config in the user deps file, when I specify the :mvn/repo on CLI via - Sdeps then it works. So it really looks like somehow it is not seeing the file content...

Alex Miller (Clojure team)16:01:06

What does verbose print when it’s not working?

Jakub Holý (HolyJak)22:01:06

Hi Alex, I am sorry, I did not see your question. As far as I remember, verbose printed the path of the file that I was writing. I suspect there is something weird with the GH Action environment / the particular actions I use for this. Anyway I have a working workaround and ton of other stuff to do 😭 so I am closing the lid on this. Thank you for your help!

twashing14:01:38

Is there a way to specify HEAD in tools.deps’ git coordinates? If I try A, I’ll get an error like B. And this corresponds with the source code C.

# A
{:deps {org.example/my-library {:git/url ""
                                :git/branch "master"
                                :git/sha "HEAD"}}}

# B
Library org.example/my-library has prefix sha, use full sha or add tag

# C

delaguardo15:01:39

you could use :git/tag "HEAD" but before starting the repl execute from the project root directory clj -X:deps resolve-git-tags to add explicit :git/sha for every dependency that declares :git/tag

2
twashing15:01:59

Hmm, getting this.

clj -X:deps resolve-git-tags
Namespace clojure.tools.cli.api loaded but function not found: resolve-git-tags

twashing15:01:38

Is there a way to make a feature request for HEAD in tools.deps’ git coordinates? We have a use case where a platform test pulls in other services. And it should always run its tests against its dependency’s main HEAD. I’m sure there’s other places it’s useful. But I don’t see a way to make feature requests on in tools.deps’ github repo.

{:deps {org.example/my-library {:git/url ""
                                :git/branch "master"
                                :git/sha "HEAD"}}}

Alex Miller (Clojure team)15:01:15

Requests can be made at https://ask.clojure.org but I can tell you in advance that this is intentionally not supported

twashing15:01:38

Ok, thanks for the feedback. Do you know the rationale, off the top of your head?

Alex Miller (Clojure team)15:01:03

If you want to “follow along” to a dep, it is better to check out the repo locally and use a :local/root dep

twashing15:01:17

Fair enough. Thanks for the backgrounder 👏:skin-tone-5:

Alex Miller (Clojure team)15:01:47

We want git deps to be fixed references to unambiguous commit points (shas)

👍 2
2
Colin P. Hill22:01:42

Anyone have much experience using the CLI in Powershell? I have a script that reads directly from *in*, and I'm trying to invoke it with gc .\game-data.json | clojure -M .\scripts\wager_returns.clj, but the input stream doesn't seem to receive the data from the pipe – it waits for interactive input.

hiredman22:01:30

how do you know it is waiting for interactive input?

Colin P. Hill22:01:55

It hangs, and then I can type things, and then the JSON parser parses what I type

Colin P. Hill22:01:42

> gc .\game-data.json | clojure -M .\scripts\wager_returns.clj
I waited a good ten seconds and then typed this
Execution error at clojure.data.json/-read (json.clj:364).
JSON error (unexpected character): I

hiredman22:01:03

sounds like '|' is the issue, I don't use PS, but if I recall, it doesn't pipe things based on raw byte streams, but instead can pass structured data

hiredman22:01:45

so maybe the output of gc is being passed via some structured data thing using |, but clojure is trying to read from stdin

Colin P. Hill22:01:51

Yeah, that was my thinking. But afaict gc (short for get-content, roughly equivalent to cat) does indeed pipe text. Might still be structured in some way though.

Colin P. Hill22:01:22

Though this SO answer seems to suggest I'm doing it right https://stackoverflow.com/a/11788475

Colin P. Hill22:01:10

I'm not sure about that – looks like they're trying to pipe into a PS script.

hiredman22:01:29

clojure is maybe a ps script?

Colin P. Hill22:01:41

hm, good point, it might be

Colin P. Hill22:01:11

PS> Get-Command clojure              

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           clojure -> Invoke-Clojure                          1.11.1.11… ClojureTools

PS> get-command invoke-clojure

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Invoke-Clojure                                     1.11.1.11… ClojureTools
Looks like you may be onto something there. A CommandType of Function sure makes it sound like it's a shell function.

Colin P. Hill23:01:45

psclj-a.ps1:

& $JavaCmd -classpath "$classpath;$InstallDir/exec.jar" clojure.main '-e' '(println "Read:" (slurp *in*))'
PS> .\psclj-a.ps1
It waited for me to type and then ^C
Read: It waited for me to type and then ^C

PS> echo "foo" | .\psclj-a.ps1
Same result!
Read: Same result!
psclj-b.ps1:
$Input | & $JavaCmd -classpath "$classpath;$InstallDir/exec.jar" clojure.main '-e' '(println "Read:" (slurp *in*))'
PS> .\psclj-b.ps1             
Read: 
PS> echo "foo" | .\psclj-b.ps1
Read: foo

Colin P. Hill23:01:32

psclj-c.ps1:

if ($MyInvocation.ExpectingInput) {
    $Input | & $JavaCmd -classpath "$classpath;$InstallDir/exec.jar" clojure.main '-e' '(println "Read:" (slurp *in*))'
} else {
    & $JavaCmd -classpath "$classpath;$InstallDir/exec.jar" clojure.main '-e' '(println "Read:" (slurp *in*))'
}
PS> echo "foo" | .\psclj-c.ps1
Read: foo

PS> .\psclj-c.ps1
Waited for input
Read: Waited for input
Seems workable to me. @U064X3EF3 Is this a known issue and/or does this seem like a reasonable solution? Not seeing any discussion of it in Slack archives or Ask Clojure, but I may have missed something.

Alex Miller (Clojure team)23:01:48

Can you restate the problem?

Colin P. Hill23:01:10

In a nutshell, the CLI on Powershell can't read piped input

Alex Miller (Clojure team)23:01:52

If there’s a bug, please file it in https://ask.clojure.org

👍 2