Unable to build Kotlin - 'The filename or extension is too long'


#1

I just recently installed JDK 7 as well as IntelliJ on my machine, and I haven't been able to build Kotlin because of the error below. Has anyone been able to fix this error?

Here’s the build log on my local machine, which is running Windows 8 and is using the JDK 7:

$ /c/apache-ant-1.9.3/bin/ant -f build.xml
Buildfile: d:Developmentkotlinbuild.xml
Trying to override old definition of task javac2
  [echo] Use javac2 from Idea lib

clean:
  [delete] Deleting directory d:Developmentkotlindist

init:
  [mkdir] Created dir: d:Developmentkotlindistkotlinc
  [mkdir] Created dir: d:Developmentkotlindistkotlinclib
  [mkdir] Created dir: d:Developmentkotlindistkotlinclibtools

prepareDist:
  [copy] Copying 4 files to d:Developmentkotlindistkotlincbin
  [copy] Copying 10 files to d:Developmentkotlindistkotlinclicense

preloader:
  [echo] Cleaning d:Developmentkotlin/dist/classes/preloader
  [mkdir] Created dir: d:Developmentkotlindistclassespreloader
  [javac2] Compiling 16 source files to d:Developmentkotlindistclassesprel
oader
  [javac2] warning: [options] bootstrap class path not set in conjunction with
-source 1.6
  [javac2] d:Developmentkotlincompilerpreloadersrcorgjetbrainsjetprelo
adingClassPreloadingUtils.java:19: warning: CompoundEnumeration is internal pro
prietary API and may be removed in a future release
  [javac2] import sun.misc.CompoundEnumeration;
  [javac2]           ^
  [javac2] d:Developmentkotlincompilerpreloadersrcorgjetbrainsjetprelo
adingClassPreloadingUtils.java:120: warning: CompoundEnumeration is internal pr
oprietary API and may be removed in a future release
  [javac2]                   return new CompoundEnumeration<URL>(new Enumerat
ion[0]);
  [javac2]                           ^
  [javac2] 3 warnings
  [javac2] Added @NotNull assertions to 0 files
  [jar] Building jar: d:Developmentkotlindistkotlinclibkotlin-preloade
r.jar

builtins:
  [echo] Cleaning d:Developmentkotlin/dist/builtins
  [mkdir] Created dir: d:Developmentkotlindistbuiltins

BUILD FAILED
d:Developmentkotlinbuild.xml:275: java.io.IOException: Cannot run program “c:
Javajdk1.7.0_51jrebinjava.exe”: CreateProcess error=206, The filename or ex
tension is too long
  at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
  at java.lang.Runtime.exec(Runtime.java:617)
  at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Jav
a13CommandLauncher.java:41)
  at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:428)
  at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:442)
  at org.apache.tools.ant.taskdefs.Java.fork(Java.java:791)
  at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:214)
  at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
  at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
  at org.apache.tools.ant.Task.perform(Task.java:348)
  at org.apache.tools.ant.Target.execute(Target.java:435)
  at org.apache.tools.ant.Target.performTasks(Target.java:456)
  at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
  at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
  at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
  at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
  at org.apache.tools.ant.Main.runBuild(Main.java:851)
  at org.apache.tools.ant.Main.startAnt(Main.java:235)
  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.io.IOException: CreateProcess error=206, The filename or extensi
on is too long
  at java.lang.ProcessImpl.create(Native Method)
  at java.lang.ProcessImpl.<init>(ProcessImpl.java:385)
  at java.lang.ProcessImpl.start(ProcessImpl.java:136)
  at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
  … 24 more

Total time: 6 seconds

Regards,

Philip Laureano


#2

I would say my set up is identical to your machine (Windows 8, JDK 1.7, ant 1.9.3), but still there's no problems with running build even after moving folder with project to longer path

Probably the most suspicious string in your description is

$ /c/apache-ant-1.9.3/bin/ant -f build.xml
Did you run the command in cmd?

#3

Hi Nickolay,

I have run it from both cmd.exe, as well as MINGW just to make sure that it wasn’t an issue that was limited to only cmd.exe. I still get the same error in from both CLIs.


#4

I see, thank you. In fact I tried MINGW, but it didn't reveal any problems on my machine too. The best thing I can suggest is to re-check that default Java is 1.7, and try everything from the very begining on c disk, just because I have one disk and this is the only difference between our machines I can see now :)

Internet menitions long class-path as the source for this class of errros, but I don’t see how this can be a problem in this particular script. You can print the classpath by modifing build.xml

274:  <target name="builtins"> 275:   <cleandir dir="${output}/builtins"/> 276:   <echo message="${toString:classpath}"/> 277:   <java classname="org.jetbrains.jet.utils.builtinsSerializer.BuiltinsSerializerPackage" failonerror="true" fork="true">           <classpath>            <path refid="classpath"/>            <pathelement location="${bootstrap.compiler.home}/lib/kotlin-compiler.jar"/>           </classpath>           <assertions>            <enable/>           </assertions>           <arg value="${output}/builtins"/>           <arg value="core/builtins/native"/>           <arg value="core/builtins/src"/>   </java>   </target>


#5

You can use “Long Path Tool” !


#6

Cannot run program “c:
Javajdk1.7.0_51jrebinjava.exe”: CreateProcess error=206, The filename or ex
tension is too long

That looks fishy to me: Shouldn’t be there backslashes?