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.This is when I run clj -M:dev where the above options are part of the dev alias.
Are you using the official CLI, or @borkdude's version?
I vaguely recall that windows has a pretty limited cli length. Maven writes the classpath to a file to work around that.
I was using official CLI. I'm going to look at @borkdude’s version to see if that helps.
The issue popped up again when I tried to add another dependency.
Hmmm, using @borkdude’s deps.exe did not seem to resolve this.
Is there a work-around?
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.cljahhh, I guess I'm not sure. I installed via`scoop install clj-deps`
This isn't the official CLI. The official CLI is presented here: https://clojure.org/guides/install_clojure#_windows_instructions
I should try installing a different way perhaps.
ok, will give this a go.
I'll try deps.clj on Windows myself now too. Which version of nREPL were you using?
not sure...
Clojure CLI version (deps.clj) 1.11.1.1273
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
Setting :mvn/local-repo to "C:/Temp/with space" also works just fine
I'll let you know if the official cli runs fine.
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
How are you invoking the CLI btw, from the command line or via other tooling?
just via command line
The official cli doesn't work for me either.
so something like clj -M:nrepl?
clj -M:dev
the official CLI: can you paste the output of clj --version?
just to verify that you are using it
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 : NativeCommandFailedok, similar error then
Clojure CLI version 1.11.1.1165seems good. and what is your java -version?
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)This time I get the error when I add my 9th dependency in the toplevel deps.
yeah, too long classpath probably... passing the classpath via a file would be the solution here.
Is there a way to force that. I did use that option when I was making an uberjar last week.
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
:use-cp-file :always
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.
can you paste me your deps.edn with top level deps? then I can try to repro on Windows over here
I can paste something close... I can't expose internal stuff at the moment.
of course
{
: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}
}
} com.mycompany/a isn't useful for me to repro, but I'll try the other deps
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
when you have a repro with only public libs, I'll try again locally
Hmmm, yeah I try to get you something like that.
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.
These have a large list of transitive dependencies that probably make the classpath very large.
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.
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...)
329 semicolons
and how long (many characters) is the file?
wc -m .cpcache/<hash>.cp
returns 33653that's # of characters
which is also the byte count
Ah, maybe it has to do with this: https://devblogs.microsoft.com/oldnewthing/20031210-00/?p=41553
sounds about right
ahh
ok, I'm at `user=> (borkdude.deps/-main "-M:nrepl-test") 22070` now, so I should keep adding some more ;)
Mine started working again at 32506 but was broken at 32800.
👍
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 long300+ deps in there ;)
I'll write a Windows-specific fix
The joys of bringing clojure to a large legacy codebase.
@pauld I think this version should work. Download the zip and run deps.exe -M:dev
https://ci.appveyor.com/project/borkdude/deps-clj/builds/47083892/artifacts
great! repl starts now
cool, I'll try to make a proper test for this and will try to release a new version tomorrow
@pauld I released it now https://clojurians.slack.com/archives/C015AL9QYH1/p1684444369418759
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
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.
actually scoop should now work too, thanks to @ales.najmann
scoop update
scoop update clj-deps