tools-deps

2023-05-11T18:54:18.414309Z

I'm getting the following error when I add a second middleware option to my main-opts

Exception in thread "main" java.io.IOException: Cannot run program "C:\Program Files\AdoptOpenJDK\jdk-11.0.5.10-hotspot\bin\java.exe": CreateProcess error=206, The filename or extension is too long
        at java.base@11.0.17/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base@11.0.17/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at borkdude.deps$shell_command.invokeStatic(deps.clj:103)
        at borkdude.deps$shell_command.invoke(deps.clj:80)
        at borkdude.deps$shell_command.invokeStatic(deps.clj:87)
        at borkdude.deps$shell_command.invoke(deps.clj:80)
        at borkdude.deps$_main.invokeStatic(deps.clj:880)
        at borkdude.deps$_main.doInvoke(deps.clj:589)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at borkdude.deps.main(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$NewObjectWithObjectArrayArgFunctionPointer.invoke(JNIFunctions.java)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.ThrowNew(JNIFunctions.java:882)
        at java.base@11.0.17/java.lang.ProcessImpl.create(ProcessImpl.java)
        at java.base@11.0.17/java.lang.ProcessImpl.<init>(ProcessImpl.java:492)
        at java.base@11.0.17/java.lang.ProcessImpl.start(ProcessImpl.java:153)
        at java.base@11.0.17/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
Here is my main-opts:
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]
I'm on windows 10 using scoop clojure. This only happens when I use a second middleware. It works fine if I only include cider-middleware.

2023-05-11T18:58:11.089779Z

This is when I run clj -M:dev where the above options are part of the dev alias.

dominicm 2023-05-12T06:39:33.751789Z

Are you using the official CLI, or @borkdude's version?

dominicm 2023-05-12T06:40:18.442929Z

I vaguely recall that windows has a pretty limited cli length. Maven writes the classpath to a file to work around that.

2023-05-18T14:02:05.204719Z

I was using official CLI. I'm going to look at @borkdude’s version to see if that helps.

2023-05-18T14:02:41.343189Z

The issue popped up again when I tried to add another dependency.

2023-05-18T14:07:38.090809Z

Hmmm, using @borkdude’s deps.exe did not seem to resolve this.

2023-05-18T14:07:49.858379Z

Is there a work-around?

borkdude 2023-05-18T14:09:55.402619Z

Are you sure you were using the official CLI?

Exception in thread "main" java.io.IOException: Cannot run program "C:\Program Files\AdoptOpenJDK\jdk-11.0.5.10-hotspot\bin\java.exe": CreateProcess error=206, The filename or extension is too long
        at java.base@11.0.17/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base@11.0.17/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at borkdude.deps$shell_command.invokeStatic(deps.clj:103)
        at borkdude.deps$shell_command.invoke(deps.clj:80)
        at borkdude.deps$shell_command.invokeStatic(deps.clj:87)
Seems to indicate you are using deps.clj

2023-05-18T14:15:52.247279Z

ahhh, I guess I'm not sure. I installed via`scoop install clj-deps`

borkdude 2023-05-18T14:16:30.428679Z

This isn't the official CLI. The official CLI is presented here: https://clojure.org/guides/install_clojure#_windows_instructions

2023-05-18T14:16:30.595389Z

I should try installing a different way perhaps.

2023-05-18T14:16:54.116949Z

ok, will give this a go.

borkdude 2023-05-18T14:16:54.410249Z

I'll try deps.clj on Windows myself now too. Which version of nREPL were you using?

2023-05-18T14:20:38.525039Z

not sure...

2023-05-18T14:21:21.529389Z

Clojure CLI version (deps.clj) 1.11.1.1273

borkdude 2023-05-18T14:25:26.914129Z

I can't repro this with deps.clj and this in :aliases: Running (borkdude.deps/-main "-A:nrepl-test") works fine. But perhaps it's the space

borkdude 2023-05-18T14:28:26.731359Z

Setting :mvn/local-repo to "C:/Temp/with space" also works just fine

2023-05-18T14:31:53.747779Z

I'll let you know if the official cli runs fine.

borkdude 2023-05-18T14:33:10.807859Z

ok, I tried various things set to the directory with spaces locally: DEPS_CLJ_TOOLS_DIR and CLJ_CONFIG, but everything runs fine here, in cmd.exe

borkdude 2023-05-18T14:33:50.510239Z

How are you invoking the CLI btw, from the command line or via other tooling?

2023-05-18T14:35:34.751509Z

just via command line

2023-05-18T14:35:53.159769Z

The official cli doesn't work for me either.

borkdude 2023-05-18T14:35:58.658369Z

so something like clj -M:nrepl?

2023-05-18T14:36:10.610959Z

clj -M:dev

borkdude 2023-05-18T14:36:30.168499Z

the official CLI: can you paste the output of clj --version?

borkdude 2023-05-18T14:36:40.311279Z

just to verify that you are using it

2023-05-18T14:36:40.695849Z

Program 'java.exe' failed to run: The filename or extension is too longAt C:\Users\Paul Dumais\Documents\WindowsPowerShell\Modules\ClojureTools\ClojureTools.psm1:453 char:7 + & $JavaCmd @JavaOpts @JvmCacheOpts @JvmOpts "-Dclojure.basis=$B ... + ~. At C:\Users\Paul Dumais\Documents\WindowsPowerShell\Modules\ClojureTools\ClojureTools.psm1:453 char:7 + & $JavaCmd @JavaOpts @JvmCacheOpts @JvmOpts "-Dclojure.basis=$B ... + ~ + CategoryInfo : ResourceUnavailable: (:) [], ParentContainsErrorRecordException

+ FullyQualifiedErrorId : NativeCommandFailed

borkdude 2023-05-18T14:37:01.095249Z

ok, similar error then

2023-05-18T14:37:10.644299Z

Clojure CLI version 1.11.1.1165

borkdude 2023-05-18T14:37:41.540129Z

seems good. and what is your java -version?

2023-05-18T14:38:04.894019Z

openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)

2023-05-18T14:39:04.088499Z

This time I get the error when I add my 9th dependency in the toplevel deps.

borkdude 2023-05-18T14:39:35.577059Z

yeah, too long classpath probably... passing the classpath via a file would be the solution here.

2023-05-18T14:40:27.629029Z

Is there a way to force that. I did use that option when I was making an uberjar last week.

borkdude 2023-05-18T14:41:19.621819Z

it's not available in the CLI yet, but it would be fixed by adding an @ sign here: https://github.com/borkdude/deps.clj/blob/4918fb6fb6f90019fbc0f5d3f3cda036fa864a4a/src/borkdude/deps.clj#L998

2023-05-18T14:41:30.810819Z

:use-cp-file :always

borkdude 2023-05-18T14:42:04.178789Z

The caveat is that this only works in Java 9+ so maybe hiding it behind an environment variable DEPS_CLJ_USE_CP_FILE or so would make sense. But I would be jumping ahead of @alexmiller in this case.

borkdude 2023-05-18T14:43:17.321169Z

can you paste me your deps.edn with top level deps? then I can try to repro on Windows over here

2023-05-18T14:44:40.943669Z

I can paste something close... I can't expose internal stuff at the moment.

borkdude 2023-05-18T14:44:51.275919Z

of course

2023-05-18T14:48:49.329319Z

{
 :paths ["src" #_"target/classes" #_"classes"]
 :mvn/repos
 {"gitlab-maven" {:url ""}
  "e-iceblue" {:url ""}}
 :deps
 {org.clojure/clojure {:mvn/version "1.11.1"}
  org.clojure/tools.namespace {:mvn/version "1.3.0"}
  org.apache.commons/commons-imaging {:mvn/version "1.0-alpha3"}
  io.github.clojure/tools.build {:mvn/version "0.9.4"}
  io.github.cljfx/dev {:mvn/version "1.0.36"}
  com.mycompany/a {:mvn/version "1.0.0"}
  com.mycompany/b {:mvn/version "1.0.0"}
  com.mycompany/c {:mvn/version "1.0.0"}
  io.github.humbleui/humbleui {:git/sha "d7c2915b4900d34b727cd2006ff0f8cca1907242"}
  }
 :aliases
 {
  :dev {:extra-deps {cider/cider-nrepl {:mvn/version "0.30.0"}}
        :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}
  :build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.4"}}
           :ns-default build}
  }
 }

borkdude 2023-05-18T14:54:13.635109Z

com.mycompany/a isn't useful for me to repro, but I'll try the other deps

borkdude 2023-05-18T14:56:08.890619Z

if you comment out the com.mycompany deps, do you still experience the problem? the other deps don't create the problem for me locally

borkdude 2023-05-18T14:58:55.662049Z

when you have a repro with only public libs, I'll try again locally

2023-05-18T16:17:52.018969Z

Hmmm, yeah I try to get you something like that.

2023-05-18T16:28:36.359679Z

I'm having difficulty reproducing this issue without one of two particular internal dependencies that can only be found in our private maven gitlab repo.

2023-05-18T16:29:11.475979Z

These have a large list of transitive dependencies that probably make the classpath very large.

borkdude 2023-05-18T17:22:01.084999Z

I tried adding 100+ libs to the deps.edn and I still couldn't reproduce but someone suggested elsewhere (in #off-topic ) that a too long filename on the classpath might trigger it.

borkdude 2023-05-18T17:23:38.671429Z

if you remove your local .cpcache directory, and then run clj -M:dev do you see a .cpcache/<hash>.cp file and what is inside of that? any long paths? how many semicolons do you see? (this would count the total number of dependencies, about...)

2023-05-18T18:01:20.678189Z

329 semicolons

borkdude 2023-05-18T18:01:57.581879Z

and how long (many characters) is the file?

2023-05-18T18:04:05.972999Z

wc -m .cpcache/<hash>.cp 
returns 33653

2023-05-18T18:04:43.134709Z

that's # of characters

2023-05-18T18:05:45.136359Z

which is also the byte count

borkdude 2023-05-18T18:07:29.195839Z

Ah, maybe it has to do with this: https://devblogs.microsoft.com/oldnewthing/20031210-00/?p=41553

borkdude 2023-05-18T18:07:39.114679Z

sounds about right

2023-05-18T18:08:19.470419Z

ahh

borkdude 2023-05-18T18:11:24.230159Z

ok, I'm at `user=> (borkdude.deps/-main "-M:nrepl-test") 22070` now, so I should keep adding some more ;)

2023-05-18T18:12:32.495389Z

Mine started working again at 32506 but was broken at 32800.

borkdude 2023-05-18T18:13:08.987899Z

👍

borkdude 2023-05-18T18:17:10.231099Z

Yep, finally I could reproduce it:

32900
Execution error (IOException) at java.lang.ProcessImpl/create (ProcessImpl.java:-2).
CreateProcess error=206, The filename or extension is too long

borkdude 2023-05-18T18:17:42.068149Z

300+ deps in there ;)

borkdude 2023-05-18T18:18:17.397839Z

I'll write a Windows-specific fix

😀 1
2023-05-18T18:23:23.024429Z

The joys of bringing clojure to a large legacy codebase.

borkdude 2023-05-18T18:49:12.418999Z

@pauld I think this version should work. Download the zip and run deps.exe -M:dev

2023-05-18T18:57:36.327689Z

great! repl starts now

borkdude 2023-05-18T19:10:48.952699Z

cool, I'll try to make a proper test for this and will try to release a new version tomorrow

👍 1
borkdude 2023-05-18T21:13:37.174089Z

@pauld I released it now https://clojurians.slack.com/archives/C015AL9QYH1/p1684444369418759

borkdude 2023-05-18T21:14:06.116689Z

it will take maybe a bit of time before clj-deps in scoop is updated but should be there in a few hours or so

borkdude 2023-05-19T09:08:25.050389Z

There is an issue with the scoop-clojure: it doesn't parse the suffixes I added to the version (`-4` ) so the package doesn't update currently. But you can use the manual powershell script and add --as-clj to install it as clj.exe and clojure.exe for now.

borkdude 2023-05-19T11:13:23.060129Z

actually scoop should now work too, thanks to @ales.najmann

borkdude 2023-05-19T11:13:30.760379Z

scoop update
scoop update clj-deps

1
😀 1