Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hangs on REPL Start: Error when starting java process due to length of classpath #1150

Closed
matthewgretton opened this issue Nov 10, 2015 · 14 comments
Labels
bug Marks issues describing bugs released Marks issues which have had the fixes released in a stable build
Milestone

Comments

@matthewgretton
Copy link

Hi,

I'm an experiencing an issue when starting REPL. It hangs at the make phase and then I have to restart intellij. Looking in the logs, that there was a problem running java due to the length of the classpath. This only seems to impact projects that have a lot of dependencies. For smaller projects I am not seeing the error due to the smaller amount of stuff on the classpath I'd imagine.

Any advice would be greatly appreciated. I'm currently unable to do development in Cursive due to this issue.

I'm running intellij 15.0 and the latest version of the cursive plug in (70)

Thanks,

Matt.

2015-11-10 18:35:21,067 [ 353596] INFO - figurations.GeneralCommandLine - Cannot run program "C:\Program Files\Java\jdk1.8.0_40\bin\java" (in directory "D:\derived-data\data-snapper"): CreateProcess error=206, The filename or extension is too long
java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.8.0_40\bin\java" (in directory "D:\derived-data\data-snapper"): CreateProcess error=206, The filename or extension is too long
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at com.intellij.execution.configurations.GeneralCommandLine.startProcess(GeneralCommandLine.java:368)
at com.intellij.execution.configurations.GeneralCommandLine.createProcess(GeneralCommandLine.java:354)
at com.intellij.execution.process.OSProcessHandler.(OSProcessHandler.java:38)
at com.intellij.execution.process.DefaultJavaProcessHandler.(DefaultJavaProcessHandler.java:35)
at cursive.repl.process_runner$process_handler.invoke(process_runner.clj:81)
at cursive.repl.process_runner$start_nrepl_server$fn__12867.invoke(process_runner.clj:130)
at cursive.repl$create_new_repl$fn__11162.invoke(repl.clj:58)
at cursive.repl.nrepl$submit$fn__3757.invoke(nrepl.clj:122)
at clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 13 more
2015-11-10 18:35:21,069 [ 353598] INFO - cursive.repl.nrepl - Shutting down REPL executor
2015-11-10 18:35:21,318 [ 353847] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: /D:/IntelliJ IDEA 15.0/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_40/lib/tools.jar;/D:/IntelliJ IDEA 15.0/lib/optimizedFileManager.jar;D:/IntelliJ IDEA 15.0/lib/ecj-4.4.jar

@cursive-ide
Copy link
Owner

Thanks for the details, I'll take a look. In the meantime, if running on the command line with lein repl works you can start a REPL with lein repl :headless and then connect to it from Cursive using a Remote REPL configuration, telling it to use the port written out by Leiningen.

@matthewgretton
Copy link
Author

Ok - Thanks, I'll give that a go

Edit: It's a maven project so not quite sure how I'd get the class path set up properly for a remote lein.

@matthewgretton
Copy link
Author

Hi,

Not sure if this is going to help with your investigations or not, but the issue only seems to be affecting projects which have a lot of maven plugin dependencies. In particular every project which has the rpm-maven-plugin as a dependency is having the issue.

Commenting out these dependencies in the pom.xml allows me to start a REPL. Not sure if this is simply that I have reduced the length of the classpath or if there is something else at play, but thought it was worth mentioning.

Either way, I have a short term solution, as I can obviously develop without the mvn rpm plugin dependency.

Thanks,

Matt.

@cursive-ide
Copy link
Owner

Ah, I see. Somq quick googling suggests that this is a generic problem, you're right that it seems that the generated classpath is too long: http://stackoverflow.com/a/10598074/155368. Since this doesn't seem to be Cursive specific, unfortunately my best advice at the moment is "don't do that", sadly.

There does seem to be a filthy hack, see here. I'd need to investigate that to see if it was suitable for all REPL executions, though.

@cursive-ide
Copy link
Owner

Allegedly IntelliJ contains a different hack for this, see here

@matthewgretton
Copy link
Author

I had seen those,

It's just I have never seen it when making/building the project outside of Cursive. When doing a make directly through intellij there is no problem.

I assumed it must be something to the way the plugin is forming the classpath. What is REPL make doing differently that the standard intellij make (ctrl f9 ) is not doing?

Thanks,

Matt.

@matthewgretton
Copy link
Author

To be clearer, it's not actually the make task that causes the issue it's

'Calculating REPL classpath'

This task may not be a cursive bit of code, but I don't see any other part of intellij calculating the classpath in the same way, so is cursive calling a particular function or something that has this issue?

If that's the case let me know exactly what the call is and I can log an issue with whoever provides that.

Thanks,

Matt.

@cursive-ide
Copy link
Owner

One thing that Cursive does is to add source directories from dependent modules to the classpath, in case there's Clojure code there you might want to use. This mimics the way that lein depends on other projects. You could try disabling this under Settings->Languages & Frameworks->Clojure.

BTW how is your REPL configured - are you using the nREPL in normal JVM process option?

@matthewgretton
Copy link
Author

Hi,

I've already tried disabling that setting, but I still had issues.

When I'm running a main method from intellij, I'm now getting an message about the classpath being to long. Intellij then offers to enable file classpaths. So as stated above, Intellij has a way of dealing with this situation. Would it be possible for Cursive to hook into this functionality?

I am using the nREPL in normal JVM process option.

Thanks,

Matt.

@matthewgretton
Copy link
Author

Hi,

Just to say, the only way I can "fix" this issue is ensure that class path file mode is enabled before trying to start any REPL instances.

I usually achieve this by trying to run a java main method (I'm sure you can set this in a settings file as well) with the offending class path, Intellij then prompts you to enable class path file mode. If you do this then the issues go away.

As correctly stated above, this is not a Cursive issue per se, however I think that if Cursive was able to hook into the 'enable file mode' logic when when REPLs are started it would be sufficient to resolve this issue once and for all.

Thanks,

Matt.

@cmf
Copy link

cmf commented Dec 7, 2015

Thanks Matt, that was helpful, searching for "classpath file mode" I've found where IntelliJ turns it on. I'll see if I can hook into that, it looks like I probably can. When I think I have a fix for this, I'll send you a dev build to test if that's ok, since it seems that you can reproduce the problem easily and I don't have access to a Windows machine.

@cursive-ide
Copy link
Owner

Having just looked at the code, I believe this issue should be obsolete these days. If this is not the case, please let me know the error that you're seeing and we can re-open this if required.

@conan
Copy link

conan commented Mar 27, 2018

I could really use some help with this. All my projects contain both clojure and clojurescript, and so they all hit this problem. I've been trying out a solution where i make a junction called r in the root directory which points at my leiningen repository, and then put this in my profiles.clj:

{:user {:local-repo "C:\\r"}}

The hope being that Cursive would construct the classpath with a prefix of C:\r\clj-http\... instead of C:\Users\conan\.m2\repository\clj-http\..., which would shorten everything. I can't get Cursive to respect my profiles.clj file though. This is complicated by the fact that running figwheel includes going via a normal JVM process instead of leiningen, but I'm guessing Cursive still uses leiningen to calculate the classpath?

I'd really appreciate any insights anyone may have as to how the classpath gets put together when running in a normal JVM process so I can get my figwheel projects working with Cursive.

@cursive-ide cursive-ide added this to the 1.7.0-eap3 milestone Apr 29, 2018
@cursive-ide cursive-ide modified the milestones: 1.7.0-eap3, 1.8.0-eap1 May 20, 2018
@cursive-ide cursive-ide reopened this Jun 18, 2018
@cursive-ide
Copy link
Owner

I'm reopening this to take a look at it - @conan, are you still suffering from this?

@cursive-ide cursive-ide added the bug Marks issues describing bugs label Sep 22, 2020
@cursive-ide cursive-ide added the released Marks issues which have had the fixes released in a stable build label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Marks issues describing bugs released Marks issues which have had the fixes released in a stable build
Projects
None yet
Development

No branches or pull requests

5 participants