This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-09
Channels
- # announcements (9)
- # beginners (69)
- # cider (4)
- # clj-kondo (8)
- # cljdoc (1)
- # clojure (52)
- # clojure-austin (4)
- # clojure-europe (22)
- # clojure-nl (2)
- # clojure-norway (14)
- # clojure-uk (3)
- # clojurescript (9)
- # conjure (4)
- # cursive (3)
- # datalevin (13)
- # datomic (4)
- # events (2)
- # fulcro (59)
- # graalvm (17)
- # helix (25)
- # inf-clojure (4)
- # integrant (4)
- # introduce-yourself (2)
- # java (5)
- # kaocha (1)
- # leiningen (3)
- # meander (7)
- # nbb (4)
- # off-topic (30)
- # portal (4)
- # rdf (1)
- # reagent (5)
- # sci (1)
- # shadow-cljs (57)
- # sql (8)
- # tools-deps (39)
- # uncomplicate (3)
- # vim (3)
- # xtdb (8)
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 😭 🙏You can use -Sverbose
to print your path info to see where it’s looking
But I think here you’re just seeing a confusing error as all repos are checked but it only reports the last failure
I would ask in #datomic and they can help diagnose there
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.
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...
What does verbose print when it’s not working?
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!
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
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
Hmm, getting this.
clj -X:deps resolve-git-tags
Namespace clojure.tools.cli.api loaded but function not found: resolve-git-tags
Ahh, it’s git-resolve-tags
https://clojure.org/reference/deps_and_cli#_other_programs
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"}}}
Requests can be made at https://ask.clojure.org but I can tell you in advance that this is intentionally not supported
If you want to “follow along” to a dep, it is better to check out the repo locally and use a :local/root dep
We want git deps to be fixed references to unambiguous commit points (shas)
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.
It hangs, and then I can type things, and then the JSON parser parses what I type
> 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
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
so maybe the output of gc is being passed via some structured data thing using |, but clojure is trying to read from stdin
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.
Though this SO answer seems to suggest I'm doing it right https://stackoverflow.com/a/11788475
https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-1246179450 sounds like what you are seeing, but with python
I'm not sure about that – looks like they're trying to pipe into a PS script.
hm, good point, it might be
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.https://github.com/clojure/brew-install/blob/1.11.1/src/main/resources/clojure/install/ClojureTools.psm1 and https://github.com/clojure/brew-install/blob/1.11.1/src/main/resources/clojure/install/ClojureTools.psd1
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
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.Can you restate the problem?
In a nutshell, the CLI on Powershell can't read piped input
Done https://ask.clojure.org/index.php/12533/cli-on-powershell-cannot-read-piped-input
clj.exe
(deps.clj disguised as clj) doesn't have this problem:
https://ask.clojure.org/index.php/12533/cli-on-powershell-cannot-read-piped-input?show=12534#a12534